Skip to content

Instantly share code, notes, and snippets.

@curtisbelt
Last active November 12, 2022 16:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save curtisbelt/cc5d247bc84c1b98fd2a9de64b2adab7 to your computer and use it in GitHub Desktop.
Save curtisbelt/cc5d247bc84c1b98fd2a9de64b2adab7 to your computer and use it in GitHub Desktop.
Node.js/PHP NGINX Config for Headless WordPress
server {
server_name climb.localhost *.climb.localhost;
root /home/curtis/Wordpress;
listen 80;
listen [::]:80;
# Catch all php files first
location ~ \.php$ {
fastcgi_keep_conn on;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
# Catch remaining WordPress-specific routing/static files
location ~ (/wp-(.*)|robots\.txt$|sitemap_index\.xml$) {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php$is_args$args;
}
# Everything else - proxy to NodeJS
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment