Getting started

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting started

James Read
I edited the config file as follows:

http {
        server {
                location / {
                        root /www;
                }
        }
...
}

I then reloaded the config file with sudo nginx -s reload. I created a test file at /www/index.html then when I tried to load the page in my browser I still got the default Welcome to nginx! page.

What am I doing wrong?

I also tried editing the page at /usr/share/nginx/html/index.html None of my edits seem to have any effect. When I tried to load the page in my browser I still got the default Welcome to nginx! page.

What's going on?

thanks,
James

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Getting started

Francis Daly
On Tue, Dec 10, 2019 at 11:50:21PM +0000, James Read wrote:

Hi there,

nginx uses a single config file, which may "include" other files.

When a request comes in to nginx, it chooses one "server" to handle
the request; and then (with some exceptions) it chooses one "location"
to handle the request.

> I edited the config file as follows:
>
> http {
>         server {
>                 location / {
>                         root /www;
>                 }
>         }
> ...
> }
>
> I then reloaded the config file with sudo nginx -s reload. I created a test
> file at /www/index.html then when I tried to load the page in my browser I
> still got the default Welcome to nginx! page.
>
> What am I doing wrong?

One possibility is that your browser had cached its previous request
to nginx, so it never asked nginx for the request this time. If you
use "curl" to make a test request of the page, it should avoid that
possibility.

Another possibility is that the config file that you edited is not the
config file that the running nginx is using.

Or maybe, the server{} that you edited is not the server{} that nginx
chooses to handle the particular request that you made.

The nginx access log file should show something if the request got to
nginx -- that might rule out the first possibility above.

The nginx error log -- especially if it is in "debug" mode -- may show far
more than you ever want to know about what nginx is doing with a request.

That *might* show something about the other possibilities.

> I also tried editing the page at /usr/share/nginx/html/index.html None of
> my edits seem to have any effect. When I tried to load the page in my
> browser I still got the default Welcome to nginx! page.

That one is most likely browser caching, I guess.

Cheers,

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Getting started

James Read

On Wed, Dec 11, 2019 at 8:30 PM Francis Daly <[hidden email]> wrote:
On Tue, Dec 10, 2019 at 11:50:21PM +0000, James Read wrote:

Hi there,

nginx uses a single config file, which may "include" other files.

When a request comes in to nginx, it chooses one "server" to handle
the request; and then (with some exceptions) it chooses one "location"
to handle the request.

> I edited the config file as follows:
>
> http {
>         server {
>                 location / {
>                         root /www;
>                 }
>         }
> ...
> }
>
> I then reloaded the config file with sudo nginx -s reload. I created a test
> file at /www/index.html then when I tried to load the page in my browser I
> still got the default Welcome to nginx! page.
>
> What am I doing wrong?

One possibility is that your browser had cached its previous request
to nginx, so it never asked nginx for the request this time. If you
use "curl" to make a test request of the page, it should avoid that
possibility.

Another possibility is that the config file that you edited is not the
config file that the running nginx is using.

Or maybe, the server{} that you edited is not the server{} that nginx
chooses to handle the particular request that you made.

The nginx access log file should show something if the request got to
nginx -- that might rule out the first possibility above.

The nginx error log -- especially if it is in "debug" mode -- may show far
more than you ever want to know about what nginx is doing with a request.

That *might* show something about the other possibilities.


Access log shows that page hasn't changed http code 304:

127.0.0.1 - - [11/Dec/2019:20:46:42 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.79 Safari/537.36"
 
> I also tried editing the page at /usr/share/nginx/html/index.html None of
> my edits seem to have any effect. When I tried to load the page in my
> browser I still got the default Welcome to nginx! page.

That one is most likely browser caching, I guess.

Cheers,

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Getting started

Francis Daly
On Wed, Dec 11, 2019 at 08:54:24PM +0000, James Read wrote:

Hi there,

> Access log shows that page hasn't changed http code 304:
>
> 127.0.0.1 - - [11/Dec/2019:20:46:42 +0000] "GET / HTTP/1.1" 304 0 "-"
> "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)
> Chrome/79.0.3945.79 Safari/537.36"

That indicates that this browser sent a request of something like "please
send me /, if it is newer than (some time in the past)", and nginx said
"/ is not newer than then".

It does not say anything about whether the "time in the past" corresponded
to /usr/local/nginx/html/index.html, and whether "not newer" corresponds
to /www/index.html. Maybe neither apply; maybe both do.


If you do

  curl -i http://127.0.0.1/

what content do you get back? Is it from the file that you want it to be?

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Getting started

James Read


On Thu, Dec 12, 2019 at 4:24 PM Francis Daly <[hidden email]> wrote:
On Wed, Dec 11, 2019 at 08:54:24PM +0000, James Read wrote:

Hi there,

> Access log shows that page hasn't changed http code 304:
>
> 127.0.0.1 - - [11/Dec/2019:20:46:42 +0000] "GET / HTTP/1.1" 304 0 "-"
> "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko)
> Chrome/79.0.3945.79 Safari/537.36"

That indicates that this browser sent a request of something like "please
send me /, if it is newer than (some time in the past)", and nginx said
"/ is not newer than then".

It does not say anything about whether the "time in the past" corresponded
to /usr/local/nginx/html/index.html, and whether "not newer" corresponds
to /www/index.html. Maybe neither apply; maybe both do.


If you do

  curl -i http://127.0.0.1/

what content do you get back? Is it from the file that you want it to be?

I still get the Welcome to nginx! page.

James
 

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Getting started

Francis Daly
On Thu, Dec 12, 2019 at 04:34:17PM +0000, James Read wrote:
> On Thu, Dec 12, 2019 at 4:24 PM Francis Daly <[hidden email]> wrote:

Hi there,

> > If you do
> >
> >   curl -i http://127.0.0.1/
> >
> > what content do you get back? Is it from the file that you want it to be?
> >
>
> I still get the Welcome to nginx! page.

Your nginx is using a config file.

You made a change to a config file.

Have you any evidence that the config file you changed is the config
file that your nginx is using?

"ps -ef | grep nginx" may show if an explicit config file is being used
("-c" argument).

If not, "nginx -V" should show the "configure arguments", which will
show any --conf-path or --prefix that will indicate the default config
file that nginx will use, if it is not the default-default.

Cheers,

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Getting started

James Read


On Thu, Dec 12, 2019 at 4:42 PM Francis Daly <[hidden email]> wrote:
On Thu, Dec 12, 2019 at 04:34:17PM +0000, James Read wrote:
> On Thu, Dec 12, 2019 at 4:24 PM Francis Daly <[hidden email]> wrote:

Hi there,

> > If you do
> >
> >   curl -i http://127.0.0.1/
> >
> > what content do you get back? Is it from the file that you want it to be?
> >
>
> I still get the Welcome to nginx! page.

Your nginx is using a config file.

You made a change to a config file.

Have you any evidence that the config file you changed is the config
file that your nginx is using?

"ps -ef | grep nginx" may show if an explicit config file is being used
("-c" argument).


root       903     1  0 Dec11 ?        00:00:00 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
www-data  9470   903  0 Dec11 ?        00:00:00 nginx: worker process
www-data  9471   903  0 Dec11 ?        00:00:00 nginx: worker process
www-data  9472   903  0 Dec11 ?        00:00:00 nginx: worker process
www-data  9473   903  0 Dec11 ?        00:00:00 nginx: worker process
www-data  9474   903  0 Dec11 ?        00:00:00 nginx: worker process
www-data  9475   903  0 Dec11 ?        00:00:00 nginx: worker process
www-data  9476   903  0 Dec11 ?        00:00:00 nginx: worker process
www-data  9477   903  0 Dec11 ?        00:00:00 nginx: worker process
yaakov   24793  8371  0 16:49 pts/0    00:00:00 grep --color=auto nginx

 
If not, "nginx -V" should show the "configure arguments", which will
show any --conf-path or --prefix that will indicate the default config
file that nginx will use, if it is not the default-default.

nginx version: nginx/1.16.1 (Ubuntu)
built with OpenSSL 1.1.1c  28 May 2019
TLS SNI support enabled
configure arguments: --with-cc-opt='-g -O2 -fdebug-prefix-map=/build/nginx-cVmHmM/nginx-1.16.1=. -fstack-protector-strong -Wformat -Werror=format-security -fPIC -Wdate-time -D_FORTIFY_SOURCE=2' --with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-z,now -fPIC' --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-compat --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream=dynamic --with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module

This is the config file that I edited /etc/nginx/nginx.conf

James

 

Cheers,

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Getting started

Francis Daly
On Thu, Dec 12, 2019 at 04:52:25PM +0000, James Read wrote:
> On Thu, Dec 12, 2019 at 4:42 PM Francis Daly <[hidden email]> wrote:

Hi there,

> > If not, "nginx -V" should show the "configure arguments", which will
> > show any --conf-path or --prefix that will indicate the default config
> > file that nginx will use, if it is not the default-default.
>
> nginx version: nginx/1.16.1 (Ubuntu)
> built with OpenSSL 1.1.1c  28 May 2019
> TLS SNI support enabled
> configure arguments: --with-cc-opt='-g -O2

> --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log
> --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock

> This is the config file that I edited /etc/nginx/nginx.conf

That looks correct to me, thanks.

When you do the "reload", do you get anything new at the end of the
error_log file, probably /var/log/nginx/error.log?

If, for example, there is a config file error, then "reload" will not
actually use the new file, and there should be something saying why.


If that shows no problems, then something like

  nginx -T | grep 'server\|listen'

should show the "server" blocks, "listen" directives, and "server_name"
configurations that nginx will use.

If you consider any of the information there private -- names, or
public IP addresses, for example -- feel free to edit them; but please
do so consistently, so that any patterns remain visible.

That configuration fragment may make it possible to learn which server{}
nginx uses to handle your test request.

Cheers,

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Getting started

James Read


On Thu, Dec 12, 2019 at 5:03 PM Francis Daly <[hidden email]> wrote:
On Thu, Dec 12, 2019 at 04:52:25PM +0000, James Read wrote:
> On Thu, Dec 12, 2019 at 4:42 PM Francis Daly <[hidden email]> wrote:

Hi there,

> > If not, "nginx -V" should show the "configure arguments", which will
> > show any --conf-path or --prefix that will indicate the default config
> > file that nginx will use, if it is not the default-default.
>
> nginx version: nginx/1.16.1 (Ubuntu)
> built with OpenSSL 1.1.1c  28 May 2019
> TLS SNI support enabled
> configure arguments: --with-cc-opt='-g -O2

> --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log
> --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock

> This is the config file that I edited /etc/nginx/nginx.conf

That looks correct to me, thanks.

When you do the "reload", do you get anything new at the end of the
error_log file, probably /var/log/nginx/error.log?

If, for example, there is a config file error, then "reload" will not
actually use the new file, and there should be something saying why.


If that shows no problems, then something like

  nginx -T | grep 'server\|listen'

should show the "server" blocks, "listen" directives, and "server_name"
configurations that nginx will use.

If you consider any of the information there private -- names, or
public IP addresses, for example -- feel free to edit them; but please
do so consistently, so that any patterns remain visible.

That configuration fragment may make it possible to learn which server{}
nginx uses to handle your test request.

I found the file /etc/nginx/sites-available/default which has the line:

 root /var/www/html;

I edited the file there and now my edits work.

James
 

Cheers,

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx

_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: Getting started

Francis Daly
On Thu, Dec 12, 2019 at 06:17:25PM +0000, James Read wrote:
> On Thu, Dec 12, 2019 at 5:03 PM Francis Daly <[hidden email]> wrote:

Hi there,

> > If that shows no problems, then something like
> >
> >   nginx -T | grep 'server\|listen'
> >
> > should show the "server" blocks, "listen" directives, and "server_name"
> > configurations that nginx will use.

> I found the file /etc/nginx/sites-available/default which has the line:
>
>  root /var/www/html;
>
> I edited the file there and now my edits work.

Good stuff; I'm glad that you found the place to make changes that
stick. And thank you for letting the list know too; that will help the
next person who has the same initial problem.

Cheers,

        f
--
Francis Daly        [hidden email]
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx