Amit Kohli
Amit Kohli

Reputation: 2950

nginx index.html does not update after modification

Sorry for noob question, I suck at Ubuntu.

I have just installed nginx in a Ubuntu server with:

sudo apt-get update
sudo apt-get -y install nginx

It successfully built. I'm trying to change the index page, so I have modified my /usr/share/nginx/html/index.html, and then tried all of these:

sudo service nginx stop
sudo service nginx start
sudo service nginx restart

But when I refresh the root page on my browser it still shows the old page.

This is what the index.html looks like:
enter image description here

I have checked my /etc/nginx/nginx.conf, but don't find anything particular there.

What could I be missing?

Upvotes: 10

Views: 23175

Answers (5)

Gopala raja naika
Gopala raja naika

Reputation: 17

Just restart your app like below

sudo systemctl restart app

Upvotes: 0

Ank_247shbm
Ank_247shbm

Reputation: 542

Build image:

 docker build -t imagename .

Detach image from localhost upstream and sync to container:

docker run -d -p 5000:80 --name containername imagename

/etc/nginx/nginx.conf:

worker_processes  5;
error_log  /etc/nginx/errors.log;
worker_rlimit_nofile 8192;

events {
    worker_connections  4096;
}

http {
 upstream client {
     server localhost:5000;
 }

 server {
    listen 80;
    listen [::]:80;

    location /{
        proxy_pass http://4a425c847f78:5000;
     }
  }
 }

Image Id :

 4a425c847f78

Forever stop ~/app/app.js :

forever stopall

Run app.js with port 80:

node app.js

Forever start ~/app/app.js with port 3000:

forever start app.js

Start Docker:

docker stop imagename
docker start imagename

Start nginx:

systemctl stop nginx
systemctl start nginx

Upvotes: 0

Jai
Jai

Reputation: 41

The correct configuration file for NGINX on Debian is :

/var/www/html/index.nginx-debian.html

If you update this file, the changes will be reflected immediately, without a start/stop or restart.

sudo service nginx stop
sudo service nginx start
sudo service nginx restart

Upvotes: 2

Kathy
Kathy

Reputation: 419

I have same problem before, then after updating nginx conf by moving 'root' from 'server/location' to 'server', it works well. Nginx config file :

server {
    listen       443 ssl;
    server_name  localhost;

    root   /usr/share/nginx/html/rdist;

    location /user/ {
        proxy_pass   http://localhost:9191;
    }
    location /api/ {
        proxy_pass   http://localhost:9191;
    }
    location /auth/ {
        proxy_pass   http://localhost:9191;
    }


    location / {
        index  index.html index.htm;
        if (!-e $request_filename){
          rewrite ^(.*)$ /index.html break;
        }
    }

Upvotes: -1

Przemysław Jagielski
Przemysław Jagielski

Reputation: 223

If you had checked vhost, you knowned, root directory is /var/www/html...

vhost is in /etc/nginx/sites-available and /etc/nginx/sites-enabled (sites-enabled is symlink).

Upvotes: 7

Related Questions