Last active
April 13, 2021 18:22
-
-
Save werelax/e61c7cd538829774fc2c to your computer and use it in GitHub Desktop.
Simple nginx config examples
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
upstream app_server { | |
server 127.0.0.1:7000; | |
keepalive 64; | |
} | |
server { | |
listen 80; | |
# listen 443 ssl; | |
server_name viviz.bettr.es www.viviz.bettr.es; | |
# ssl_certificate /etc/nginx/ssl/nginx.crt; | |
# ssl_certificate_key /etc/nginx/ssl/nginx.key; | |
if ($host = 'www.viviz.bettr.es' ) { | |
rewrite ^/(.*)$ http://viviz.bettr.es/$1 permanent; | |
} | |
# error_page 502 /errors/502.html; | |
root /var/www/viviz/static/; | |
# only proxy if no static file is found | |
try_files $uri $uri/ @gateway; | |
access_log off; | |
expires max; | |
location @gateway { | |
proxy_redirect off; | |
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; | |
proxy_set_header Host $http_host; | |
proxy_set_header Connection ""; | |
proxy_http_version 1.1; | |
proxy_cache_key sfs$request_uri$scheme; | |
proxy_pass http://app_server; | |
} | |
} |
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
upstream app_server { | |
server 127.0.0.1:8000; | |
keepalive 64; | |
} | |
server { | |
listen 80; | |
listen 443 ssl; | |
server_name dashboard.seetransparent.com; | |
ssl_certificate /etc/letsencrypt/live/dashboard.seetransparent.com/fullchain.pem; | |
ssl_certificate_key /etc/letsencrypt/live/dashboard.seetransparent.com/privkey.pem; | |
if ($scheme = http) { | |
return 301 https://$server_name$request_uri; | |
} | |
# error_page 502 /errors/502.html; | |
root /var/www/dups-dashboard/static/; | |
# only proxy if no static file is found | |
try_files $uri $uri/ @gateway; | |
access_log off; | |
expires max; | |
location / { | |
proxy_redirect off; | |
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; | |
proxy_set_header Host $http_host; | |
proxy_set_header Connection ""; | |
proxy_http_version 1.1; | |
proxy_cache_key sfs$request_uri$scheme; | |
proxy_pass http://app_server; | |
} | |
location @gateway { | |
proxy_redirect off; | |
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; | |
proxy_set_header Host $http_host; | |
proxy_set_header Connection ""; | |
proxy_http_version 1.1; | |
proxy_cache_key sfs$request_uri$scheme; | |
proxy_pass http://app_server; | |
} | |
} |
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
server { | |
listen 80; | |
listen [::]:80; | |
listen 443 ssl; | |
server_name site.example.com www.site.example.com; | |
if ($host = 'www.site.example.com' ) { | |
rewrite ^/(.*)$ http://site.example.com/$1 permanent; | |
} | |
# error_page 502 /errors/502.html; | |
root /home/user/html; | |
index index.html; | |
location / { | |
try_files $uri $uri/ =404; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To create self-signed SSL certificates (useful for webhooks) look at this guide