1

I'm deploying Symfony 4 application which will be available through proxy: https://proxydomain.com/application

The application works when it's accessed with the URL without trailing slash: https://proxydomain.com/application but when I add the shlash at the end(https://proxydomain.com/application/) nginx returns 404.

Here is the log fragment of this two examples:

172.20.83.254 - - [11/Jun/2019:16:10:06 +0200] "GET / HTTP/1.1" 200 316 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/74.0.3729.169 Chrome/74.0.3729.169 Safari/537.36"
172.20.83.254 - - [11/Jun/2019:16:10:03 +0200] "GET // HTTP/1.1" 404 522 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/74.0.3729.169 Chrome/74.0.3729.169 Safari/537.36"

And here is my nginx configuration file:

server {
        server_name _;
        root /var/www/application/public;

        location / {
                # try to serve file directly, fallback to app.php
                try_files $uri /index.php$is_args$args;
        }

        # PROD
        location ~ ^/index\.php(/|$) {
                fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
                fastcgi_split_path_info ^(.+\.php)(/.*)$;
                include fastcgi_params;
                # When you are using symlinks to link the document root to the
                # current version of your application, you should pass the real
                # application path instead of the path to the symlink to PHP
                # FPM.
                # Otherwise, PHP's OPcache may not properly detect changes to
                # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126
                # for more information).
                fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
                fastcgi_param DOCUMENT_ROOT $realpath_root;
                # Prevents URIs that include the front controller. This will 404:
                # http://domain.tld/app.php/some-path
                # Remove the internal directive to allow URIs like this
                internal;
   }

   # return 404 for all other php files not matching the front controller
   # this prevents access to other php files you don't want to be accessible.
   location ~ \.php$ {
         return 404;
   }

   error_log /var/log/nginx/application_error.log;
   access_log /var/log/nginx/application_access.log;
}

Do you know what can I do to make it work?

0 Answers0