nginx and WordPress in a subdirectory

daveyfx nginx-forum at nginx.us
Tue Aug 6 05:40:48 UTC 2013


Hello -

I've got nginx as a front-end to Apache and am trying to serve a single
WordPress site from a location on my site.  Right now I would like to test
the location, but it will eventually be served as /advertise.  I cannot get
the WordPress site to serve correctly, however as I am seeing a 301 redirect
infinite loop.

nginx location directive:

    location ^~ /advertise-wp {
        include /usr/local/nginx/proxypass.conf;
        proxy_pass http://nsweb1.nstein.prod:90;
    }

contents of /usr/local/nginx/proxypass.conf:
proxy_redirect     off;
proxy_set_header   Host             $host;
proxy_set_header   X-Real-IP        $remote_addr;
proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;

Apache configuration:
Listen 90

<VirtualHost *:90>
    ServerName www.sitename.com
    ServerAlias nsweb1.nstein.prod

    DocumentRoot /opt/nstein/advertise
    ErrorLog /var/log/apache2/www_error.log
    CustomLog /var/log/apache2/www_access.log combined
    DirectoryIndex index.php

</VirtualHost>

<Directory "/opt/nstein/advertise">
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
</Directory>

I have tried to make this work properly by setting these in wp-config.php as
well, to no avail.
define('WP_HOME', 'http://www.sitename.com/advertise-wp');
define('WP_SITEURL', 'http://www.sitename.com/advertise-wp');

Thanks for your help.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,241623,241623#msg-241623



More information about the nginx mailing list