51 lines
1.6 KiB
Plaintext
51 lines
1.6 KiB
Plaintext
|
server {
|
||
|
listen 80;
|
||
|
listen [::]:80;
|
||
|
server_name domain.tld;
|
||
|
access_log off;
|
||
|
root /srv/http/domain.tld/dist/chat;
|
||
|
include /etc/nginx/acme.conf;
|
||
|
location / {
|
||
|
return 301 https://domain.tld$request_uri;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
server {
|
||
|
listen 443 ssl http2;
|
||
|
listen [::]:443 ssl http2;
|
||
|
server_name domain.tld;
|
||
|
|
||
|
ssl_certificate /etc/letsencrypt/live/domain.tld/fullchain.pem;
|
||
|
ssl_certificate_key /etc/letsencrypt/live/domain.tld/privkey.pem;
|
||
|
|
||
|
access_log /var/log/nginx/domain.tld.access.log;
|
||
|
error_log /var/log/nginx/domain.tld.error.log;
|
||
|
root /srv/http/domain.tld/dist/appname;
|
||
|
|
||
|
location / {
|
||
|
try_files $uri @dumpdom;
|
||
|
}
|
||
|
|
||
|
location @dumpdom {
|
||
|
proxy_set_header Host $host;
|
||
|
set $dumpdom 0;
|
||
|
if ($http_user_agent ~* "googlebot|bingbot|yandex|baiduspider|twitterbot|facebookexternalhit|rogerbot|linkedinbot|embedly|quora link preview|showyoubot|outbrain|pinterest|slackbot|vkShare|W3C_Validator|whatsapp|DuckDuckBot|redditbot|Discordbot|Viber") {
|
||
|
set $dumpdom 1;
|
||
|
}
|
||
|
if ($args ~ "_escaped_fragment_") {
|
||
|
set $dumpdom 1;
|
||
|
}
|
||
|
if ($http_user_agent ~ "Prerender") {
|
||
|
set $dumpdom 0;
|
||
|
}
|
||
|
if ($uri ~* "\.(js|css|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 $dumpdom 0;
|
||
|
}
|
||
|
if ($prerender = 1) {
|
||
|
proxy_pass http://127.0.0.1:9292;
|
||
|
}
|
||
|
if ($prerender = 0) {
|
||
|
rewrite .* /index.html break;
|
||
|
}
|
||
|
}
|
||
|
}
|