I have a wordpress hosted on Apache2 with Nginx in front of.
<WORLD> ===> <NGINX PROXY> --> APACHE/DOCKER/STATIC WEBSITE etc...
My nginx conf for wordpress proxy is :
server { server_name dev-www.example.com; location / { proxy_pass http://127.0.0.1:13400; } }
My apache configuration :
Listen 13400 <VirtualHost 127.0.0.1:13400> CustomLog /var/log/httpd/sites/dev-www/access_log combined ErrorLog /var/log/httpd/sites/dev-www/error_log DirectoryIndex index.php DocumentRoot /var/www/sites/example.com/dev-www RewriteEngine On <Directory /var/www/sites/example.com/dev-www/> Options Indexes FollowSymLinks AllowOverride all </Directory> </VirtualHost>
And wordpress .htaccess
:
# BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . index.php [L] </IfModule> # END WordPress
The issue is when I go on dev-www.example.com/foobar.php
I am redirected to 127.0.0.1/foobar.php
. I know it’s from nginx
configuration 127.0.0.1
pop out put how to fix it ?
I try to proxy pass to dev-www.example.com:13400
but I got an infinite loop :
[Tue May 10 23:44:45.001680 2016] [core:error] [pid 1096] [client 127.0.0.1:54887] AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use ‘LimitInternalRecursion’ to increase the limit if necessary. Use ‘LogLevel debug’ to get a backtrace., referer: http://dev-www.example.com/
note: there is no problem with http://dev-www.example.com
or http://dev-www.example.com/index.php
Thanks.
note2 : If I change nginx configuration to localhost:13400, then i’m redirected to localhost/login-3. It looks like .htaccess redirect to ServName and it is 127.0.0.1
Advertisement
Answer
It’s wordpress redirect to HTTP_HOST
, adding
$_SERVER['HTTP_HOST'] = $_SERVER['HTTP_X_FORWARDED_HOST'];
in wp-config.php
fix it.