Skip to content

Instantly share code, notes, and snippets.

@elijahsgh
Created March 15, 2019 15:23
Show Gist options
  • Save elijahsgh/5c93bcbcfecb270465b5b265d68faa59 to your computer and use it in GitHub Desktop.
Save elijahsgh/5c93bcbcfecb270465b5b265d68faa59 to your computer and use it in GitHub Desktop.
nginx unitd with wordpress for 1.8.0+
{
"listeners": {
"*:8080": {
"pass": "routes/wordpress"
}
},
"routes": {
"wordpress": [
{
"match": {
"uri": "/wp-admin/*"
},
"action": {
"pass": "applications/indexphp"
}
},
{
"match": {
"uri": "*.php"
},
"action": {
"pass": "applications/indexphp"
}
},
{
"action": {
"pass": "applications/scriptphp"
}
}
]
},
"applications": {
"scriptphp": {
"type": "php",
"root": "/var/www/wordpress",
"script": "index.php",
"user": "www-data",
"group": "www-data",
"processes": 1
},
"indexphp": {
"type": "php",
"root": "/var/www/wordpress",
"index": "index.php",
"user": "www-data",
"group": "www-data",
"processes": 1
}
}
}
upstream wordpress {
server 127.0.0.1:8080;
}
server {
listen 80 default_server;
server_name _;
root /var/www/wordpress;
location = /favicon.ico {
log_not_found off;
access_log off;
expires max;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location / {
try_files $uri @wordpress;
}
location ~ \.php$ {
proxy_pass http://wordpress;
proxy_set_header Host $host;
}
location @wordpress {
proxy_pass http://wordpress;
proxy_set_header Host $host;
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|webm|webp)$ {
try_files $uri =404;
expires max;
log_not_found off;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment