Skip to content

Instantly share code, notes, and snippets.

@moyarich
Created April 17, 2020 17:14
Show Gist options
  • Save moyarich/fbb0507ebf26712a8a403baaf99d2dc1 to your computer and use it in GitHub Desktop.
Save moyarich/fbb0507ebf26712a8a403baaf99d2dc1 to your computer and use it in GitHub Desktop.
# forward web traffic from https://api.examplewebsite.com to http://127.0.0.1:6000
#file location: /etc/nginx/conf.d/virtual.conf
server {
listen 80;
listen 443 ssl;
server_name api.examplewebsite.com;
ssl_certificate /etc/ssl/ssl_2020/certbundle.pem;
ssl_certificate_key /etc/ssl/ssl_2020/key/examplewebsite.key;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_ciphers 'ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:AES128-GCM-SHA256:AES128-SHA256:AES128-SHA:AES256-GCM-SHA384:AES256-SHA256:AES256-SHA:DES-CBC3-SHA';
ssl_session_timeout 5m;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m; # a 1mb cache can hold about 4000 sessions, so we can hold 40000 sessions
location / {
root /var/www/api.examplewebsite.com/public_html/;
index index.html index.htm;
}
location /v1/ {
proxy_pass http://127.0.0.1:6000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
access_log /var/log/nginx/nginx.api.examplewebsite.com.access.log;
error_log /var/log/nginx/nginx.api.examplewebsite.com.error.log;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment