| 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