Add Nginx virtualhost example
Opened this issue · 0 comments
goldyfruit commented
Nginx example with TLS support should be added to the documentation.
20-api.domain.io.conf
server {
listen 80;
server_name api.domain.io;
root /srv/data/web/api.domain.io;
index index.html index.htm index.php;
location /.well-known/acme-challenge/ {
try_files $uri /dev/null =404;
}
location / {
return 301 https://$host$request_uri;
}
access_log /srv/data/logs/web/api.domain.io/access-80.log;
error_log /srv/data/logs/web/api.domain.io/error-80.log;
}
server {
listen 443 ssl http2;
server_name api.domain.io;
root /srv/data/web/api.domain.io;
index index.html index.htm index.php;
include snippets/ssl-api.domain.io.conf;
include snippets/ssl-params.conf;
location / {
proxy_pass http://10.22.56.1:8100;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
access_log /srv/data/logs/web/api.domain.io/access-443.log;
error_log /srv/data/logs/web/api.domain.io/error-443.log;
}
ssl-params.conf
ssl_certificate /etc/letsencrypt/live/api.domain.io/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/api.domain.io/privkey.pem;
ssl-api.domain.io.conf
# from https://cipherli.st/
# and https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
ssl_ciphers "EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH";
ssl_ecdh_curve secp384r1;
ssl_session_cache shared:SSL:10m;
ssl_session_tickets off;
ssl_stapling on;
ssl_stapling_verify on;
ssl_dhparam /etc/ssl/certs/dhparam.pem;
resolver 8.8.8.8 8.8.4.4 valid=300s;
resolver_timeout 5s;
# Disable preloading HSTS for now. You can use the commented out header line that includes
# the "preload" directive if you understand the implications.
#add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload";
add_header Strict-Transport-Security "max-age=63072000; includeSubdomains";
add_header X-Frame-Options sameorigin;
add_header X-Content-Type-Options nosniff;