Opened 7 years ago

Closed 7 years ago

#1342 closed defect (invalid)

Problem without server_name with directive `index`

Reported by: alexpts@… Owned by:
Priority: minor Milestone:
Component: nginx-core Version: 1.13.x
Keywords: index Cc: alexpts@…
uname -a: docker exec -it api-invest-nginx uname -a
Linux a8f7cd4130c3 4.9.36-moby #1 SMP Wed Jul 12 15:29:07 UTC 2017 x86_64 Linux
nginx -V: docker exec -it api-invest-nginx nginx -V
nginx version: nginx/1.13.3
built by gcc 6.2.1 20160822 (Alpine 6.2.1)
built with OpenSSL 1.0.2k 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --modules-path=/usr/lib/nginx/modules --conf-path=/etc/nginx/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --http-client-body-temp-path=/var/cache/nginx/client_temp --http-proxy-temp-path=/var/cache/nginx/proxy_temp --http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp --http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp --http-scgi-temp-path=/var/cache/nginx/scgi_temp --user=nginx --group=nginx --with-http_ssl_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_random_index_module --with-http_secure_link_module --with-http_stub_status_module --with-http_auth_request_module --with-http_xslt_module=dynamic --with-http_image_filter_module=dynamic --with-http_geoip_module=dynamic --with-threads --with-stream --with-stream_ssl_module --with-stream_ssl_preread_module --with-stream_realip_module --with-stream_geoip_module=dynamic --with-http_slice_module --with-mail --with-mail_ssl_module --with-compat --with-file-aio --with-http_v2_module

Description

I use official docker image
Image ID nginx:alpine
Container ID a8f7cd4130c3f264e0691ec10328b16c2e42060a9d7b323e5bd67cc0c29ad75a

My config:

server {
    listen 80;

    root /var/www/html/projects/api-invest/public/;
    index index.php;

    location = / {
        try_files $uri /index.php?$args;
    }

    location ~ \.php$ {
        fastcgi_pass api-invest-fpm:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }
}

I try open uri / and nginx pass me for download file index.php. (expected pass request to fastcgi)
I try open uri /index.php and nginx pass request to fastcgi.

I add server_name inv.local;
I try open uri / and nginx pass request to fastcgi backend.

Change History (1)

comment:1 by Maxim Dounin, 7 years ago

Resolution: invalid
Status: newclosed

The config provided is a configuration of a particular server{} block, not a full configuration. Full configuration can be found in /etc/nginx/nginx.conf and included files, and can be also obtained by using nginx -T.

The fact that adding server_name helps suggests that the server block in question is not default, and without server_name requests are handled in the different server block, the default one. It doesn't look there is a bug here.

Please see http://nginx.org/en/docs/http/request_processing.html for some introductory information on request processing in nginx, it should help you to understand what goes on in the particular configuration. If you have further questions, please consider support options available.

Note: See TracTickets for help on using tickets.