Nginx php reverse proxy problem

adrian.hilt nginx-forum at forum.nginx.org
Wed Feb 12 12:43:11 UTC 2020


Hi, 
I'm running a reverse proxy with nginx and using certbot for ssl. It's been
working great but recently with an php server installation it's been giving
me problems.
I get access to the index but any other page I get a 404 error from nginx.

404 Not Found
nginx/1.14.0 (Ubuntu)

This is my conf file
server {

    root /var/www/YOUR_DIRECTORY;
    index index.php index.html index.htm;

    ###################################################
    # Change "yoururl.com" to your host name

    server_name my-domain;

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

    location /site/ {
      if (!-e $request_filename){
        rewrite ^/site/(.*)$ /site/index.php break;
      }
    }location ~ \.php$ {
        try_files $uri =404;
        fastcgi_pass unix:/var/run/php5-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param PATH_TO_FRAMEWORKS /var/www/frameworks/;
        fastcgi_param CORE_TYPE frameworks;
        fastcgi_param IS_DEV true;
        include fastcgi_params;
    }

    location = /favicon.ico {
        log_not_found off;
        access_log off;
    }

    location = /robots.txt {
        allow all;
        log_not_found off;
        access_log off;
   }

    location ~ /\. {
        deny all;
    }

    location ~* /(?:uploads|files)/.*\.php$ {
        deny all;
    }location / {
   proxy_pass http://my-server-ip/;
 }





    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/my-domain/fullchain.pem; #$
    ssl_certificate_key /etc/letsencrypt/live/my-domain/privkey.pem;$
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}
server {
    if ($host = my-domain) {
        return 301 https://$host$request_uri;
    } # managed by Certbot
    listen 80;

    server_name my-domain;
    return 404; # managed by Certbot


}


Any had similar problems? It's nginx having a different configuration for
php?
Just in case I have tried commenting the last lines which appears to send
the 404, but it did the same thing.

Posted at Nginx Forum: https://forum.nginx.org/read.php?2,287003,287003#msg-287003



More information about the nginx mailing list