WordPress redirecting connections on port 8080 to 80

I have a wordpress blog which is served by apache2(on port 80) and nginx(on port 8080) on Ubuntu 12.04.
Now whenever a client connects via port 80 all is hunky dory, but when a client connects to 8080 to view the same blog, the connection is redirected to apache. Why is this happening? I searched around and found that this is a WordPress limitation that it redirects all connections to the Site URL set in the dashboard(which is port 80 by default).

Is there a way around this? that the connections to port 8080 would be served by nginx rather than apache

Read More

Contents of /etc/nginx/sites-enabled/wordpress

server {
listen   8080;

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

server_name abc.com;

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;
}

Any help is appreciated.

Related posts

2 comments

  1. I solved it!! here’s how:

    Edit your current theme’s functions.php and add following line after the opening PHP tag to disable canonical redirection.

    remove_filter('template_redirect','redirect_canonical'); save and exit.

    Restart apache2 and nginx and check with curl -I IP.

  2. Same problem. In my situation, I set the server port at 3030, to accommodate other servers. Anyway, without having to add any code to any functions.php files, I solved the problem by changing the site and home values in the wp_options table to the domain and port setting.

    For example,

    site     http://localhost:3030
    home     http://localhost:3030
    

    Everything seemed to work fine from there. 👍

Comments are closed.