Difference between revisions of "Nginx PHP - Server blocks config template"
(Created page with "Nginx Server blocks config template (http and https) for php websites and web application <pre>upstream php-handler { #server 127.0.0.1:9000; server unix:/var/run/php...") |
(No difference)
|
Latest revision as of 02:33, 31 October 2019
Nginx Server blocks config template (http and https) for php websites and web application
upstream php-handler { #server 127.0.0.1:9000; server unix:/var/run/php/php7.1-fpm.sock; } server { listen 443 ssl; listen [::]:443 ssl; include snippets/ssl-certs.conf; include snippets/ssl-params.conf; server_name www.website.tld website.local; root /var/www/ROOT; index index.php index.html; add_header 'Access-Control-Max-Age' 1728000 always; #error_page 403 /core/templates/403.php; #error_page 404 /core/templates/404.php; location / { try_files $uri $uri/ =404; } error_page 403 /403.html; location = /403.html { root /var/www/403; internal; } error_page 404 /404.html; location = /404.html { root /var/www/404; internal; } } server { listen 80; listen [::]:80; server_name www.website.tld website.local; root /var/www/ROOT; index index.php index.html; add_header 'Access-Control-Max-Age' 1728000 always; #error_page 403 /core/templates/403.php; #error_page 404 /core/templates/404.php; location / { try_files $uri $uri/ =404; } error_page 403 /403.html; location = /403.html { root /var/www/403; internal; } error_page 404 /404.html; location = /404.html { root /var/www/404; internal; } }
File snippets/ssl-certs.conf
ssl_protocols TLSv1.2; ssl_prefer_server_ciphers on; ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384; ssl_ecdh_curve secp384r1; # Requires nginx >= 1.1.0 ssl_session_timeout 10m; ssl_session_cache shared:SSL:10m; ssl_session_tickets off; # Requires nginx >= 1.5.9 # ssl_stapling on; # Requires nginx >= 1.3.7 # ssl_stapling_verify on; # Requires nginx => 1.3.7 resolver 8.8.8.8 8.8.4.4 valid=300s; resolver_timeout 5s; #add_header X-Frame-Options DENY; #add_header X-Content-Type-Options nosniff; #add_header X-XSS-Protection "1; mode=block";
File snippets/ssl-certs.conf
ssl_certificate /etc/ssl/certs/nginx-selfsigned.crt; ssl_certificate_key /etc/ssl/private/nginx-selfsigned.key;