nginx does not use modified index file - html

I installed nginx on my raspberry pi, and configured it.
However, it does not work as what I want.
The IP of raspberry pi is 192.168.0.182, so I made index.html fil and typed in my browser. But, it show nginx's default message, not my index.html.
If I use 192.168.0.182/index.html, it shows my index.html.
What I want it not to use "/index.html" after IP address for index.html. How shoud I configure nginx?
This is my nginx configuration in /etc/nginx/site-available.
server{
listen 80;
root /home/xaliver/Web/www;
index index.html index.htm;
}
and I linked it by
sudo ln -s /etc/nginx/site-available/mysite /etc/nginx/site-enalbled/
Also, I putted index.html in /home/xaliver/Web/www/. The index.html is
"Hello World"
Please, let me know what I missed.
Thank you.

Related

Flask and Nginx: css not recognized

I am trying to deploy my website using Flask. Everything is working perfectly locally (localhost:5000), but when I deploy it on my distant linux ubuntu server (www.linode.com) I encouter a problem. I have installed gunicorn and nginx, but my CSS files are not taken into account, thus, my webpage just appears as an HTML content alone, without shape/colors and so on.
I am very new at web development, and I don't understand why it works perfectly locally and not anymore (not totally) on the linux server. Is the problem related to the nginx that can't manage to do the link between HTML and CSS? Because locally I don't need to use nginx, and everything works.
Here is my nginx config file for when I type sudo nano /etc/nginx/sites-enabled/assets:
server {
listen 80;
server_name 45.79.250.111;
include /etc/nginx/mime.types;
location /static {
alias /home/gardy/ladybird_site/assets/static;
}
location / {
proxy_pass http://localhost:8000;
include /etc/nginx/proxy_params;
proxy_redirect off;
}
}
And here is my website directory tree:
ladybird_site/
requirements.txt
run.py
assets/
__init__.py
config.py
models.py
fonts/
et-line.eot
...
fontawesome-webfont.woff2
main/
routes.py
__init__.py
templates/
index.html
layout.html
static/
css/
animate.css
bootstrap.min.css
font-awesome.min.css
style.css
bxslider/
jquery.bxslider.css
images/
bx_loader.gif
controls.png
et-line-font/
style.css
magnific-popup/
magnific-popup.css
owl-carousel/
owl.carousel.css
owl.theme.css
owl.transitions.css
images/
ldb_ico.ico
founder_pics/
custom_pics/
f1.jpg
f2.jpg
f3.jpg
ldb_imgs/
1.png
2.png
3.png
js/
bootstrap-hover-dropdown.min.js
bootstrap.min.js
...
jquery.bxslider.min.js
main.js
I am getting crazy with that stuff, trying and modifying things since two days without significant improvments, and found no answers on the internet...
Thanks a lot
Your static path looks fine. You have set your server to listen to port 80, which is the default port for HTTP, but maybe you have not opened it. The next step is for you to open it.
sudo ufw allow http/tcp
You mention that your server is still listening to port 5000. However, if you are done with testing, you can disallow this port from being used by Nginx.
sudo ufw delete allow 5000
Enable these new rules by running the command below:
sudo ufw enable
# Hit 'y' for 'yes' when prompted
Finally, you can now restart your Nginx server:
sudo systemctl status nginx.service
If you navigate to your application's IP address, and append static/css/style.css, you should be able to access your CSS file. I mean http://<your IP address>/static/css/style.css

execute index.html on internet access to server

I'm running Apache on Ubuntu 14.04. I'm Port Forwarding 8080 to my server. I've edited ports.conf to Listen 8080. I have an index.html in /var/www/html. when I browse to MyURL:8080 I get An Index of / that shows html as a directory.
If I click the html directory icon, my index.html executes. I looked at /etc/apache2/sites-available/default-ssl.conf and 000-default.conf, they both show DocumentRoot /var/www/html. So does sites-enabled/000-default.conf.
Any help on what to try next to get the index.html to execute on entry to the server would be appreciated.
I'm by no means an expert on ubuntu's apache configuration, but through some quick searching I found this http://www.ajopaul.com/2010/05/01/ubuntu-apache2-change-default-documentroot-varwww/
Is it necessary to have a trailing "/" on the document root path?

Apache2: Index.html Loads on IP but not on Domain Name (Ubuntu)

I made an AWS EC2 Instance and get an Elastic IP.
The Elastic IP was used to set a Domain Name (Bought from GoDaddy) to the AWS EC2 Instance.
The EC2 Instance is running an Apache2 server.
According to the manual, I'm supposed to replace index.html in /var/www/html/ with the index.html of my own, which I did.
When I use the Elastic IP, the index.html page that I set is displayed.
However when I use the Domain Name, for some reason it gives me the default apache2 page, even though that file no longer exists since it was overwritten. I can access the index.html with DomainName.in/index.html.
Simply put :
- DomainName.in gives apache2 default index.html which shouldn't exist anymore
- DomainName.in/index.html gives the page that I want to show up
- ElasticIP and ElasticIP/index.html both give the page I want to show up
How can I make it so that just typing the Domain Name in the browser will take me to the index.html page that I want it to go to ?
You need to set DirectoryIndex in your virtualhost configuration which is located here: /etc/apache2/apache2.conf
If that is not where your config file is located, you can find it by running: /usr/sbin/apache2 -V | grep SERVER_CONFIG_FILE
<virtualhost *:80>
ServerName domain.com
ServerAlias www.domain.com
# Index file and Document Root (where the public files are located)
DirectoryIndex home.html index.html
DocumentRoot /var/www
</virtualhost>
Ok so it turns out everything is fine, but the changes take time to propagate through the DNS for some reason.
The changes register after about half an hour.

Digital Ocean HTML Files Uploaded Not Working

I have uploaded some html files to my Digital Ocean droplet, on directory /var/www/html, but apparently I still can't connect to http://vps-ip-address, how can I make those files work on default http port when simply typing http://vps-ip-address? I know I'm missing something out and it's probably a newbie mistake, so if someone could explain to me how it can be done, I would be grateful.
By default on Ubuntu, the document root for Nginx is located at /usr/share/nginx/html In order to serve content from /var/www/html you will need to edit your Nginx configuration. The default configuration file is /etc/nginx/sites-enabled/default
Find the line:
root /usr/share/nginx/html;
and change it to:
root /var/www/html;
Then restart Nginx with sudo service nginx restart

nginx only serving welcome index page

I'm running nginx off of EC2 server
to try to troubleshoot this I created a separate directory usr/loca/nginx/html/test and put a copy of the index.html file there. I deleted the original index.html file from usr/loca/nginx/html
here is my relevant code...
nginx.conf.default
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
include usr/local/nginx/conf/*.conf
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
server_name localhost;
location / {
root html/test;
index index.html index.htm;
}
}
i try to access the site by http://'public ip address'/index.html and all i get is the default nginx startup page; even though i deleted this file, and even though i changed the text in the original index.html file to something else
i tried reloading nginx and clearing cache etc.....
I think your root directive is not pointing to the correct location. Your root directive is relative i.e. relative to the current folder. This is a very bad thing to do. Always do root relative directive. I will do something like
/home/user/www/localhost
You can choose a directory of you liking but make it root relative. Note the leading slash. If welcome page is working then NGINX is working correctly and the fault usually lies in wrong root directive. You can also make the following improvements.
First of all get the root out of sever block. Putting root in the server block is bad.
http://nginx.org/en/docs/beginners_guide.html#proxy
Why is your Nginx configuration file called nginx.conf.default? It should just be called nginx.conf (this may also be leading to the problem). See if you have a file called nginx.conf and make changes to that.
Why are you declaring the server inside nginx.conf? It is better to declare it inside a folder like
sites-available/localhost
sites-available/somesite
...
Then create a symlink to sites-enabled. This is not required but it is a good practice.