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; # } }