Query on nginx. conf file regarding redirection.

Kaushal Shriyan kaushalshriyan at gmail.com
Sat Oct 31 01:18:00 UTC 2020


On Sat, Oct 31, 2020 at 5:13 AM Francis Daly <francis at daoine.org> wrote:

> On Fri, Oct 30, 2020 at 10:45:14PM +0530, Kaushal Shriyan wrote:
> > On Fri, Oct 30, 2020 at 4:35 AM Francis Daly <francis at daoine.org> wrote:
>
> Hi there,
>
> > > What does the nginx access log or error log say happened to that
> request?
>
> > I am seeing this below message when I hit
> > http://219.11.134.114/test/_plugin/kibana/app/kibana
> >
> > ==> /var/log/nginx/error.log <==
> > 2020/10/30 17:10:57 [error] 9616#0: *20 open()
> > "/usr/share/nginx/html/test/_plugin/kibana/app/kibana" failed (2: No such
> > file or directory), client: 14.98.153.6, server: , request: "GET
> > /test/_plugin/kibana/app/kibana HTTP/1.1", host: "219.11.134.114"
> >
> > ==> /var/log/nginx/access.log <==
> > 14.98.153.6 - - [30/Oct/2020:17:10:57 +0000] "GET
> > /test/_plugin/kibana/app/kibana HTTP/1.1" 404 3650 "-" "Mozilla/5.0
> > (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like
> Gecko)
> > Chrome/86.0.4240.111 Safari/537.36" "-"
>
> When a request comes to nginx, first it decides which server{} you
> have configured to handle the request; then it decides which location{}
> in that server{} you have configured to handle the request (more or less).
>
> In this case, the request is being handled by looking at the filesystem;
> that means that it is handled in a location{} that does not have a
> proxy_pass or other similar handler defined.
>
> >  # TEST
> >     server {
>
> If you have shown the complete server{} block, then this is not the
> server{} block that the running nginx is using to handle this request.
>
> Maybe there is another location{} in the same server{} block? Or maybe
> there is another server{} in the same configuration? Or maybe the running
> nginx is using a different configuration?
>
>
> Some variant of "ps" should show your running nginx and any "-c" argument
> it has; if you copy that much and add "-T", then find the "server" and
> "listen" lines, it might help identify which server{} block is actually
> configured to be used for this request.
>
> Something like
>
>   /usr/local/sbin/nginx -c /etc/nginx.conf -T | grep -e 'server\|listen'
>
> where the first three words match whatever your system is doing, will
> probably be helpful.
>
> (Do read the output, and edit any information you consider private,
> before pasting into email.)
>
> > Also, I am not sure why it is getting referenced to
> /usr/share/nginx/html/?
> > Is there a way to change the default document root? Please suggest
> further.
>
> Yes, there is -- root (http://nginx.org/r/root).
>
>
>
Hi Francis,

I am sharing the output of cat /etc/nginx/nginx.conf

OS version : CentOS Linux release 7.8.2003 (Core)
nginx version: nginx/1.16.1

cat /etc/nginx/nginx.conf

> # For more information on configuration, see:
> #   * Official English Documentation: http://nginx.org/en/docs/
> #   * Official Russian Documentation: http://nginx.org/ru/docs/
> user nginx;
> worker_processes auto;
> error_log /var/log/nginx/error.log;
> pid /run/nginx.pid;
> # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
> include /usr/share/nginx/modules/*.conf;
> events {
>     worker_connections 1024;
> }
> http {
>     log_format  main  '$remote_addr - $remote_user [$time_local]
> "$request" '
>                       '$status $body_bytes_sent "$http_referer" '
>                       '"$http_user_agent" "$http_x_forwarded_for"';
>     access_log  /var/log/nginx/access.log  main;
>     sendfile            on;
>     tcp_nopush          on;
>     tcp_nodelay         on;
>     keepalive_timeout   65;
>     types_hash_max_size 2048;
>     include             /etc/nginx/mime.types;
>     default_type        application/octet-stream;
>     # Load modular configuration files from the /etc/nginx/conf.d
> directory.
>     # See http://nginx.org/en/docs/ngx_core_module.html#include
>     # for more information.
>     include /etc/nginx/conf.d/*.conf;
>
> #    PROD
> #    server {
> #     listen 80;
> #     location /prod {
> #            proxy_set_header   X-Forwarded-For $remote_addr;
> #    proxy_set_header   Host $http_host;
> #         #   fastcgi_read_timeout 240;
> #            proxy_connect_timeout 600;
> #            proxy_send_timeout 600;
> #            proxy_read_timeout 600;
> #            send_timeout 600;
> #    proxy_pass
> https://vpc-lab-prod-search-zvf5bfbabstbb7gi5sklqh7ll4.eu-west-1.es.amazonaws.com/
> ;
> #        }
> #        error_page 404 /404.html;
> #            location = /40x.html {
> #        }
> #
> #     #       location = /img {
> #     #      index index.html index.htm index.php;
> #     #      root /var/www/html/images/;
> #     #   }
> #
> #      location /img {
> #      root   html;
> #      index  index.php index.html index.htm;
> #      }
> #        error_page 500 502 503 504 /50x.html;
> #            location = /50x.html {
> #        }
> #    }
>     # TEST
>     server {
>      listen 80;
>      location /test {
>         proxy_set_header   X-Forwarded-For $remote_addr;
>         proxy_set_header   Host $http_host;
>         #fastcgi_read_timeout 240;
>         proxy_connect_timeout 600;
>         proxy_send_timeout 600;
>         proxy_read_timeout 600;
>         send_timeout 600;
>         proxy_pass
> https://vpc-lab-test-search-3nrzc66u2ffd3n4ywapz7jkrde.eu-west-1.es.amazonaws.com/
> ;
>         }
>         error_page 404 /404.html;
>             location = /40x.html {
>         }
>         error_page 500 502 503 504 /50x.html;
>             location = /50x.html {
>         }
>     }
> }



#nginx -c /etc/nginx/nginx.conf -T | grep -e 'server\|listen'
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
#    server {
#     listen 80;
    server {
     listen 80;

Please let me know if you need more details. Thanks in advance.

Best Regards,

Kaushal
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20201031/a8bcad15/attachment.htm>


More information about the nginx mailing list