-
-
Save MrMMorris/fa0b99e1d12a7533d7cb to your computer and use it in GitHub Desktop.
This file contains 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; | |
server_name _; | |
rewrite ^ https://$server_name$request_uri? permanent; | |
} | |
server { | |
listen 443; | |
server_name _; | |
root /usr/share/nginx/html/dist; | |
ssl on; | |
ssl_certificate /etc/nginx/ssl/self.crt; | |
ssl_certificate_key /etc/nginx/ssl/self.key; | |
location / { | |
try_files $uri $uri/ /index.html; | |
} | |
# attempt to load static files, if not found route to @rootfiles | |
location ~ (.+)\.(html|json|txt|js|css|jpg|jpeg|gif|png|svg|ico|eot|otf|woff|woff2|ttf)$ { | |
try_files $uri @rootfiles; | |
} | |
# check for app route "directories" in the request uri and strip from request | |
# rewrite file path to https if behind proxy | |
location @rootfiles { | |
if ($http_x_forwarded_proto = https) { | |
rewrite ^/(?:product|feature|legal)/(.*) https://$http_host/$1 redirect; | |
} | |
if ($http_x_forwarded_proto != https) { | |
rewrite ^/(?:product|feature|legal)/(.*) /$1 redirect; | |
} | |
} | |
# redirect server error pages to the static page /50x.html | |
# | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment