I have a Wordpress instance running on first nginx server ( Virtual Machine A ) . I can work with perfectly fine locally, everythings is well resolved and all path are accessed ( like /wp-admin/ , /wp-content/ , /wp-includes/ etc... ) thru my url www.corph.mouradcloud.com
As for now, I am not using SSL, so this a later issue :)
here is the config of my Nginx web instance :
upstream php-wp {
server unix:/var/run/mouradcloud.sock;
}
server {
listen 80;
listen [::]:80;
server_name www.corph.mouradcloud.com;
root /var/www/mouradcloud;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ .php$ {
include fastcgi.conf;
fastcgi_pass php-wp;
}
location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
I have a second Nginx server that I use as a Proxy with a different URL ( Virtual Machine B ) . After a little of google, I noticed that some other parameters need to be added to have the PHP scripts thru proxy either.
here is the proxy nginx file :
server {
listen 80;
listen [::]:80;
server_name www.mouradcloud.com;
location / {
proxy_pass http://www.corph.mouradcloud.com;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
}
}
Strangely, when a client is connecting using the web browser dbugger the path /wp-content/ , /wp-includes/ are resolved thru :
www.corph.mouradcloud.com
instead of
www.mouradcloud.com
here is the screenshot of the debugger, we can see that only documents are passing thru the proxy, scripts are rejected while it should not since I am passing every thing thru the proxy in the request..
My guess is there is some parameters that I am missing.
I tryed to add other location like /wp-includes/ , but I ended up screwing everything ...
I reviewed all the SO thread but noone has an answers so far
After searching around I found the solution. It was ... simple... So I will share every part of the config for people to not lose time in the future...
Here is the overall situations
Remember, As for this first try, I will not use SSL with Let's encrypt, I will keep it for later. For now, this is simple http.
On the NGINX Proxy, I create a site with this config file ( /etc/nginx/sites-available/www.mouradcloud.com )
server {
listen 80;
server_name www.mouradcloud.com;
location / {
proxy_pass http://www.corph.mouradcloud.com;
sub_filter_once off;
sub_filter 'www.corph.mouradcloud.com' 'www.mouradcloud.com';
sub_filter_types *;
}
}
On the VM Wordpress&Nginx, here is the wp-config.php (/var/www/mouradcloud/wp-config.php ), I did added thos 2 lines :
define('WP_SITEURL', 'http://www.corph.mouradcloud.com');
define('WP_HOME', 'http://www.corph.mouradcloud.com');
lastly in my WM WOrdpress&Nginx, I did not changed the configuration of my nginx web server and this is still the same ( /etc/nginx/sites-available/www.corph.mouradcloud.com) :
upstream php-wp {
server unix:/var/run/mouradcloud.sock;
}
server {
listen 80;
listen [::]:80;
server_name www.corph.mouradcloud.com;
root /var/www/mouradcloud;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ .php$ {
include fastcgi.conf;
fastcgi_pass php-wp;
}
location ~* .(js|css|png|jpg|jpeg|gif|ico)$ {
expires max;
log_not_found off;
}
}
Not Http is working I will have a look to https...