summaryrefslogtreecommitdiffstats
path: root/example-nginx-server.conf
blob: 1c38cb9db98c063be1b06cb5ca76f93fc1355968 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
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;
#       }
}