Last active
January 28, 2019 00:50
-
-
Save nguyentienlong/2d955b45c84cf94809f727c4e789d2d0 to your computer and use it in GitHub Desktop.
wordpress subdir on nginx with anther nodejs web app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
root /home/thixanvat/prod/web; | |
server_name thixanvat.com www.thixanvat.com; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header Host $http_host; | |
proxy_set_header X-NginX-Proxy true; | |
location /assets/ { | |
alias /home/thixanvat/prod/web/build/public/assets/; | |
add_header Cache-Control public; | |
} | |
location /googled66e20f90cafdfc7.html { | |
try_files $uri =404; # googled66e20f90cafdfc7.html; | |
} | |
# sitemaps | |
rewrite /blog/sitemap(-+([a-zA-Z0-9_-]+))?\.xml$ "/blog/index.php?xml_sitemap=params=$2" last; | |
rewrite /blog/sitemap(-+([a-zA-Z0-9_-]+))?\.xml\.gz$ "/blog/index.php?xml_sitemap=params=$2;zip=true" last; | |
rewrite /blog/sitemap(-+([a-zA-Z0-9_-]+))?\.html$ "/blog/index.php?xml_sitemap=params=$2;html=true" last; | |
rewrite /blog/sitemap(-+([a-zA-Z0-9_-]+))?\.html.gz$ "/blog/index.php?xml_sitemap=params=$2;html=true;zip=true" last; | |
# adding trailing slash to the end | |
rewrite ^([^.]*[^/])$ $1/ permanent; | |
location /blog/ { | |
access_log /var/log/nginx/blog/access.log; | |
error_log /var/log/nginx/blog/error.log; | |
alias /home/thixanvat/blog/; | |
index index.php; | |
# url permanant | |
rewrite ^/blog/wp-admin/$ /blog/wp-admin/options-general.php permanent; | |
rewrite ^/blog/(.*)/$ /blog/index.php?$1 last; | |
location ~ \.php$ { | |
include /etc/nginx/fastcgi_params; | |
fastcgi_pass unix:/run/php/php7.1-fpm.sock; | |
fastcgi_param SCRIPT_FILENAME $request_filename; | |
} | |
} | |
fastcgi_param SCRIPT_FILENAME $request_filename; | |
} | |
} | |
location = /robots.txt { | |
allow all; | |
log_not_found off; | |
access_log off; | |
} | |
location / { | |
rewrite ^/assets(.*)$ $1 break; | |
proxy_set_header Upgrade $http_upgrade; | |
proxy_set_header Connection "upgrade"; | |
proxy_max_temp_file_size 0; | |
proxy_pass http://127.0.0.1:8000; | |
proxy_redirect off; | |
proxy_read_timeout 240s; | |
} | |
listen 443 ssl; # managed by Certbot | |
ssl_certificate /etc/letsencrypt/live/thixanvat.com/fullchain.pem; # managed by Certbot | |
ssl_certificate_key /etc/letsencrypt/live/thixanvat.com/privkey.pem; # managed by Certbot | |
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot | |
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot | |
} | |
server { | |
if ($host = www.thixanvat.com) { | |
return 301 https://$host$request_uri; | |
} # managed by Certbo | |
} | |
# managed by Certbot | |
if ($host = thixanvat.com) { | |
return 301 https://$host$request_uri; | |
} # managed by Certbo | |
} | |
# managed by Certbot | |
listen 80; | |
server_name thixanvat.com www.thixanvat.com; | |
return 404; # managed by Certbot | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment