I'd like host review branches for staging, to test and get feedback before publishing to production. I tried to follow some documentation provided online such as the NGINX recipes ( https://www.nginx.com/resources/wiki/start/topics/recipes/wordpress/ ) without success! So, how to fix it?
The pattern for the review branches are /review-xxxxx
or /review-xx_x-xxx
. As I have setup the Deployment pipeline to trigger publishing to AWS ECS for review-*
branches and that's where I'd like to keep it private for tests and feedback only.
I've hard typed /review-ci
to avoid having to troubleshoot any regex pattern issues and keep it simple to start with. So, you'll find the /review-ci
path in the NGINX Conf file, so that it's clear what the goal is.
My NGINX conf file looks like:
server {
listen 80;
server_name httpwordpress.docker.localhost;
# Logs
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
# Default location settings
location / {
index index.php;
}
location /review-ci {
index index.php;
try_files $uri $uri/ /review-ci/index.php?$args;
}
# Pass the PHP scripts to FastCGI server
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name;
include fastcgi_params;
}
}
I have perm links active and I should be able to request foobar.com/review-ci/wp-admin
and see the login screen.
When I do curl http://httpwordpress.docker.localhost/review-ci/wp-admin
, I get:
404 page not found
I'm also using https://github.com/wp-graphql/wp-graphql
, which means that the address http://httpwordpress.docker.localhost/review-ci/graphql
should return a data response, but instead, I get 404.
This is a small step before I introduce a regex pattern, as I'd like to deploy the application to AWS ECS. And I noticed straight away that this failed with my original setup which I exposed and requested for help in serverfault ( https://serverfault.com/questions/988035/nginx-location-regex-for-prefixed-paths-failure ).
Meanwhile, simply relying on the hostname and ROOT path as seen bellow works fine in the development environment. But unfortunately, staging might have concurrent versions that have separate features or requirements not ready for publishing and it's kept separate by concern or "git branch name" prefixed by review-
if required to deploy and have a staging url
.
server {
listen 80;
server_name httpwordpress.docker.localhost;
root /var/www/html;
index index.php;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
client_max_body_size 200m;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php-fpm:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
client_max_body_size 200m;
}
}
Does anyone know how to fix this?
Thanks for looking and any feedback or hint is appreciated!