Last active
March 16, 2016 08:39
-
-
Save NicolasMahe/3c1044ff07c6b41c2529 to your computer and use it in GitHub Desktop.
Configuration files for nginx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Replace every VARIABLE | |
server { | |
server_name YOUR_SERVER_NAME; | |
listen 80 default_server; | |
listen [::]:80 default_server; | |
return 301 https://$server_name$request_uri; | |
} | |
server { | |
server_name YOUR_SERVER_NAME; | |
root PATH_TO_PUBLIC_WEBSITE_FOLDER; | |
listen 443 ssl default_server http2; | |
listen [::]:443 ssl default_server http2; | |
index index.php index.html index.htm; | |
# SSL | |
include PATH_TO_NGINX_CONFIG_FOLDER/nginx_ssl_SPECIFIC.conf; | |
# Laravel | |
#include PATH_TO_NGINX_CONFIG_FOLDER/nginx_laravel.conf; | |
# Auth Basic Default | |
#include PATH_TO_NGINX_CONFIG_FOLDER/nginx_auth_basic_default.conf; | |
# PHP 5 | |
#include PATH_TO_NGINX_CONFIG_FOLDER/nginx_php5.conf; | |
#PHP 7 | |
#include PATH_TO_NGINX_CONFIG_FOLDER/nginx_php7.conf; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# to generate your dhparam.pem file, run in the terminal | |
sudo openssl dhparam -out /etc/ssl/certs/dhparam.pem 2048 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Except letsencrypt folder | |
location / { | |
auth_basic "Restricted"; | |
auth_basic_user_file /etc/nginx/.htpasswd; | |
} | |
location /.well-know { | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
client_max_body_size 5M; | |
location / { | |
try_files $uri $uri/ /index.php?$query_string; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location ~ \.php$ { | |
try_files $uri /index.php =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
location / { | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header Host $http_host; | |
proxy_pass http://IP:PORT; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copy and personalize those directives in the nginx config file. Don't forget to remove the # | |
#ssl_certificate PATH_TO_SSL_FOLDER/fullchain.pem; | |
#ssl_certificate_key PATH_TO_SSL_FOLDER/privkey.pem; | |
#ssl_trusted_certificate PATH_TO_SSL_FOLDER/chain.pem; | |
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains"; | |
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH'; | |
ssl_dhparam /etc/ssl/certs/dhparam.pem; | |
ssl_prefer_server_ciphers on; | |
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; | |
ssl_session_cache shared:SSL:10m; | |
ssl_session_timeout 10m; | |
ssl_stapling on; | |
ssl_stapling_verify on; | |
resolver 8.8.8.8 8.8.4.4 valid=300s; | |
resolver_timeout 5s; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copy and personalize those directives in the nginx config file. Don't forget to remove the # | |
ssl_certificate PATH_TO_SSL_FOLDER/fullchain.pem; | |
ssl_certificate_key PATH_TO_SSL_FOLDER/privkey.pem; | |
ssl_trusted_certificate PATH_TO_SSL_FOLDER/chain.pem; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment