-1

I have a problem with an Apache+Wordpress machine (Debian). By default it listens over port 80, I have changed it and now "listens" over port 9090.

/etc/Apache2/ports.conf
[...]
NameVirtualHost *:9090
Listen 0.0.0.0:9090
[...]

/etc/apache2/sites-available/default
[...]
<VirtualHost *:9090>
[...]

When I tried to access via http://10.250.10.70:9090 y doesnt work. (Chrome error: ERR_CONNECTION_REFUSED)

Over the same machine if I try wget http://10.250.10.70:9090/ -O - I get this output:

--2015-05-14 12:31:43--  http://10.250.10.70:9090/
Connecting to 10.250.10.70:9090... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://10.250.10.70/ [following]
--2015-05-14 12:31:43--  http://10.250.10.70/
Connecting to 10.250.10.70:80... failed: Connection refused.

If I listen over port 80 too, but not changing /etc/apache2/sites-available/default

/etc/Apache2/ports.conf
[...]
NameVirtualHost *:9090
Listen 0.0.0.0:9090
Listen 0.0.0.0:80
[...]

WebSite works over port 80 (really I dont know why because NameVirtualHost only should work with port 9090). Also if I access via port 9090 works, but redirects to same URI with port 80 If I execute over the webserver again wget http://10.250.10.70:9090/ -O - I get this response:

--2015-05-14 12:38:16--  http://10.250.10.70:9090/
Connecting to 10.250.10.70:9090... connected.
HTTP request sent, awaiting response... 301 Moved Permanently
Location: http://10.250.10.70/ [following]
--2015-05-14 12:38:16--  http://10.250.10.70/
Connecting to 10.250.10.70:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: unspecified [text/html]
Saving to: `STDOUT'

    [<=>                                    ] 0           --.-K/s              <!DOCTYPE html>
[...]

First of all, I dont know why VirtualHost works over port 80, and second why this system redirect any traffic I listen to (9090 in this case), to port 80...

Im completely "lost"

Thanks you all

NOTE:

root@TWBLOG:~# apache2 -v
Server version: Apache/2.2.22 (Debian)
Server built:   Dec 23 2014 22:48:29
3
  • This question might be better moved to SuperUser.
    – James Yale
    May 14, 2015 at 11:23
  • As @krt states, it seems some firewall problem, could you provide the output of iptables -L -n ? May 14, 2015 at 11:52
  • I think thats not the problem. IPTables on this machine is "disabled" root@TWBLOG:~# iptables -L -n Chain INPUT (policy ACCEPT) target prot opt source destination Chain FORWARD (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination
    – pasapepe
    May 15, 2015 at 8:14

2 Answers 2

1

It's most likely the firewall causing the problems. Open up port 9090 with this:

sudo iptables -A INPUT -p tcp --dport 9090 -j ACCEPT

If you're using ufw:

sudo ufw allow 9090

If you would like to redirect all request on port 80 to 9090:

sudo iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 9090
0

The application (WordPress) is generating the redirect - you should check the WordPress configuration and set it's base URI to reflect the new port you're accessing it on.

See also the WordPress docs on changing the setting: http://codex.wordpress.org/Changing_The_Site_URL

When Apache gets a request that doesn't match a <VirtualHost> definition it uses the default, which is the first (or only) one it finds. This should explain why requests hitting port 80 are still hitting the VirtualHost for WordPress.

Lastly, check the firewall on the machine is allowing connections to the new listen port if you're having trouble connecting from external machines.

1
  • I know this "new" question is not suitable for sererfault (maybe for superuser), but... Is possible to listen from two different ports (80 and 9090) using the same WordPress instance?
    – pasapepe
    May 15, 2015 at 8:16

You must log in to answer this question.

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