diff options
-rw-r--r-- | example-nginx-server.conf | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/example-nginx-server.conf b/example-nginx-server.conf new file mode 100644 index 0000000..1c38cb9 --- /dev/null +++ b/example-nginx-server.conf @@ -0,0 +1,37 @@ +upstream backend { + server localhost:3030; +} + +server { + listen 80; + listen [::]:80; + + server_name app.example.com; + + return 301 https://$server_name$request_uri; +} + +server { + listen 443 default_server ssl; + server_name app.example.com; + + ssl_certificate /path/to/app.example.com.pem.crt; + ssl_certificate_key /path/to/app.example.com.pem.key; + + location /api/ { + proxy_pass http://backend/; + } + + # If static app on CDN / GH pages / other static server + location / { + # Any path other than the locations in the regex should be rewritten + # to `/`, as these are routes within the React (i.e. Client-side) Router + rewrite ^/(?!index\.html|static|.*\.ico|logo[0-9]+\.png)(.*)$ / break; + proxy_pass "https://our-app.cdn.example.com"; + } + + # Alternatively, if static files are on this machine +# location / { +# root /www-public; +# } +} |