Last active
August 9, 2016 19:09
-
-
Save dhanush/27a8e8fe13f898078433 to your computer and use it in GitHub Desktop.
NGINX configuration for having a nodejs server and wordpress behind an Nginx reverse proxy
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
upstream backend { | |
server <IP1>:<PORT>; | |
server <IP2>:<PORT>; | |
} | |
server { | |
listen 80; | |
server_name geektrust.in; | |
return 301 https://www.geektrust.in$request_uri; | |
} | |
server { | |
listen 80; | |
server_name www.geektrust.in; | |
return 301 https://www.geektrust.in$request_uri; | |
} | |
server { | |
listen 443; | |
ssl on; | |
ssl_certificate <path_to_ssl_crt> | |
ssl_certificate_key <path_to_ssl_key> | |
server_name www.geektrust.in; | |
port_in_redirect off; | |
autoindex on; | |
root /var/www/html; | |
location / { | |
root <path_to_application_directory_which_has_index_file>; | |
index index.html | |
try_files $uri $uri/ /index.html=404; | |
} | |
location /api { | |
proxy_set_header Host $http_host; | |
proxy_pass http://backend; | |
} | |
location /blog { | |
index index.php index.html index.htm; | |
try_files $uri $uri/ /blog/index.php?q=$uri&$args; | |
} | |
location ~ \.php$ { | |
fastcgi_split_path_info ^(/.+\.php)(/.+)$; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
location ~ /\.ht { | |
deny all; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment