0

I have a wordpress blog setup on apache2 (port 80) on Ubuntu 12.04, I also have a nginx setup listening on port 8080 serving the same blog. My problem is, whenever I try to open the blog on port 8080, nginx redirects the requests to apache which shouldn't happen. I'm posting the contents of /etc/nginx/sites-enabled/wordpress

server {
    listen   8080;

    root /var/www;
    index index.php index.html index.htm;

    server_name foobartech.strangled.net:8080;

    location / {
            try_files $uri $uri/ /index.php?q=$uri&$args;
    }

    location /doc/ {
            alias /usr/share/doc/;
            autoindex on;
            allow 127.0.0.1;
            deny all;
    }

    error_page 404 /404.html;

    error_page 500 502 503 504 /50x.html;
    location = /50x.html {
            root /usr/share/nginx/www;
    }

    location ~ \.php$ {

            try_files $uri =404;
            fastcgi_pass unix:/var/run/php5-fpm.sock;
            fastcgi_index index.php;
            include fastcgi_params;
            fastcgi_param   SERVER_PORT 8080;
            port_in_redirect off;
    }

I have also set cgi.fix_pathinfo=0

in /etc/php5/fpm/php.ini

2 Answers 2

2

This is a limitation in WordPress. It follows the URL you've set in the options, so that every request/link will get redirected to the site URL, which uses port 80 by default.

See http://wordpress.org/support/topic/alternate-port-setup

0
1

I solved it!! here's how:

Edit your current theme's function.php and add following line after the opening php tag remove_filter('template_redirect','redirect_canonical'); save and exit

Now open your wp-includes/ms-settings.php and find the following line (line no: ~23)

if ( !isset( $current_site ) || !isset( $current_blog ) ) {

after this line add:

$_SERVER['HTTP_HOST'] = preg_replace( '|:\d+$|', '', $_SERVER['HTTP_HOST'] );

and save & exit. Restart apache2 and nginx and check with curl -I IP that the requests aren't getting redirected.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .