Home tmade.de

Home Wiki

nginx

Example configuration nginx with PHP 7:

server {
        listen       80;
        server_name  localhost test.domain.de www.test.domain.de;
        root         /var/www/test.domain.de;
        index index.php index.html index.htm;
        #index index.php index.html index.htm default.html default.htm;

        access_log /var/log/nginx/domain-access.log;
        error_log /var/log/nginx/domain-error.log;

        location ~* /(images|cache|media|logs|tmp)/.*\.(php|pl|py|jsp|asp|sh|cgi)$ {
           return 403;
           error_page 403 /403_error.html;
        }

        ## PHP scripts to FastCGI
        location ~ [^/]\.php(/|$) {
           fastcgi_split_path_info ^(.+?\.php)(/.*)$;

                   if (!-f $document_root$fastcgi_script_name) {
           return 404;
           }

        # Mitigate https://httpoxy.org/ vulnerabilities
        fastcgi_param HTTP_PROXY "";

        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        #fastcgi_pass   localhost:9000;
        #fastcgi_pass 127.0.0.1:9000;

        #fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        #Look for the FastCGI Process Manager at this location
        fastcgi_index index.php;

        include fastcgi_params;
        }

        # caching of files
        location ~* \.(ico|pdf|flv)$ {
              expires 1y;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|swf|xml|txt)$ {
              expires 7d;
        }
}
ssl_certificate /etc/letsencrypt/live/test.de/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/test.de/privkey.pem;
ssl_trusted_certificate /etc/letsencrypt/live/test.de/fullchain.pem;
server/nginx.txt · Last modified: 2019/01/24 12:25 by tmade
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 4.0 International
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki