Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
prod.conf
# https://github.com/SocialEngine/docker-nginx-spa
# http://www.cicoria.com/forcing-tls-https-on-azure-web-apps-for-linux/
# https://github.com/GaryB432/angular-pwa/blob/master/nginx.conf
charset utf-8;
tcp_nopush on;
tcp_nodelay off;
client_header_timeout 10s;
client_body_timeout 10s;
client_max_body_size 10m;
reset_timedout_connection on;
gzip on;
gunzip on;
gzip_types text/css
text/javascript
text/xml
text/plain
application/javascript
application/x-javascript
application/json
application/xml
application/rss+xml
application/atom+xml
font/truetype
font/opentype
image/svg+xml;
server {
listen 80 default_server;
listen [::]:80 default_server;
index index.html;
root /app;
sendfile off;
error_log stderr debug;
location /graphql {
#this is resolve on domain change
resolver 127.0.0.11 ipv6=off;
proxy_pass http://backend-graphql.web.1/graphql;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /api {
#this is resolve on domain change
resolver 127.0.0.11 ipv6=off;
proxy_pass http://backend-api.web.1/api;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /portal {
#this is resolve on domain change
resolver 127.0.0.11 ipv6=off;
proxy_pass http://backend-portal.web.1/portal;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header X-Forwarded-Proto $scheme;
}
location /plausible {
#this is resolve on domain change
resolver 127.0.0.11 ipv6=off;
proxy_pass http://plausible.web.1/;
proxy_set_header Host $http_host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
# proxy_set_header Connection 'upgrade';
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location / {
# try_files $uri$args $uri$args/ /index.html;
try_files $uri @prerender;
}
location @prerender {
set $prerender 0;
if ($http_user_agent ~* "googlebot|bingbot|yandex|baiduspider|twitterbot|facebookexternalhit|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator" ) {
set $prerender 1;
}
if ($args ~ "_escaped_fragment_" ) {
set $prerender 1;
}
if ($http_user_agent ~ "Prerender" ) {
set $prerender 0;
}
if ($uri ~* "\.(js|css|webp|xml|less|png|jpg|jpeg|gif|pdf|doc|txt|ico|rss|zip|mp3|rar|exe|wmv|doc|avi|ppt|mpg|mpeg|tif|wav|mov|psd|ai|xls|mp4|m4a|swf|dat|dmg|iso|flv|m4v|torrent|ttf|woff|svg|eot)" ) {
set $prerender 0;
}
resolver 127.0.0.11 ipv6=off;
if ($prerender = 1) {
proxy_pass http://rendertron:3000/render/$scheme://$host$request_uri?wc-inject-shadydom=true;
}
if ($prerender = 0) {
rewrite .* /index.html break;
}
}
location = /index.html {
if ($http_x_debug) {
add_header X-debug-request "$request";
add_header X-debug-host "$host";
add_header X-debug-args "$args";
add_header X-debug-uri "$uri";
add_header X-debug-301 "https://$host$request_uri";
add_header X-debug-arr-ssl "$http_x_arr_ssl";
add_header X-debug-port "$remote_port";
add_header X-debug-scheme "$scheme";
}
}
# This block will catch static file requests, such as images, css, js
# The ?: prefix is a 'non-capturing' mark, meaning we do not require
# the pattern to be captured into $1 which should help improve performance
location ~* \.(?:webp|ico|css|js|gif|jpe?g|png)$ {
# Some basic cache-control for static files to be sent to the browser
expires max;
add_header Pragma public;
add_header Cache-Control "public, must-revalidate, proxy-revalidate";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment