Skip to content

Instantly share code, notes, and snippets.

@maitrungduc1410
Created February 17, 2020 05:25
Show Gist options
  • Save maitrungduc1410/84ce3953f774235360dcb376befca15b to your computer and use it in GitHub Desktop.
Save maitrungduc1410/84ce3953f774235360dcb376befca15b to your computer and use it in GitHub Desktop.
Nginx forward request to Docker container
server {
#root /var/www/html/portfolio/public;
server_name jamesisme.com www.jamesisme.com;
if ($host = jamesisme.com) {
return 301 https://www.jamesisme.com$request_uri;
}
location / {
proxy_pass http://127.0.0.1:6060;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header x-forwarded-for $remote_addr;
proxy_cache_bypass $http_upgrade;
}
location ~* \.(?:ico|gif|jpe?g|png|woff2?|eot|otf|ttf|svg|js|css)$ {
proxy_pass http://127.0.0.1:6060;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_set_header x-forwarded-for $remote_addr;
proxy_cache_bypass $http_upgrade;
expires 365d;
more_set_headers Pragma public;
more_set_headers Cache-Control "public";
}
listen [::]:443 ssl http2 ipv6only=on; # managed by Certbot
listen 443 ssl http2; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
#ssl_certificate /etc/letsencrypt/live/jamesisme.com-0001/fullchain.pem; # managed by Certbot
#ssl_certificate_key /etc/letsencrypt/live/jamesisme.com-0001/privkey.pem; # managed by Certbot
ssl_certificate /var/www/ssl_certs/jamesisme.crt;
ssl_certificate_key /var/www/ssl_certs/jamesisme.rsa;
# OCSP Stapling
# fetch OCSP records from URL in ssl_certificate and cache them
ssl_stapling on;
ssl_stapling_verify on;
# verify chain of trust of OCSP response using Root CA and Intermediate certs
ssl_trusted_certificate /var/www/ssl_certs/trusted.crt;
resolver 8.8.8.8 8.8.4.4;
}
server {
if ($host = www.jamesisme.com) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = jamesisme.com) {
return 301 https://www.$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name jamesisme.com www.jamesisme.com;
return 404; # managed by Certbot
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment