2

For each development sites I want to have a unique port number. For instance, domain.com:1234

This is what I have in my httpd.conf file. After restart the page domain.com:1234 is not showing in the browser. Is there anything else that I need to do besides what I have already done to make this work?

Listen *:1234

<VirtualHost *:1234>
DocumentRoot /var/www/dev_sites/test
ServerName domain.com
</VirtualHost>

It looks like if I go to my local hostname (kk.local:1234) it shows. Is there some sort of dns that I need to do? I really don't want to go into godaddy everytime I add a development site. Is there a way around that?

5
  • What does it says netstat -tulnp ? Do you see anything listening on port 1234 ?
    – golja
    Oct 27, 2012 at 13:18
  • Looks like it is...tcp 0 0 :::1234 :::* LISTEN -
    – user983223
    Oct 27, 2012 at 13:20
  • Does domain.com resolve to the correct address on the client? Does the browser show an error message? Does the website access show in your Apache log files? Oct 28, 2012 at 0:42
  • @AnsgarWiechers - domain.com resolves correctly along with just entering the ip of the machine. Also my local hostname:port works. domain.com:1234 and ip:port does not. It is like it doesn't allow external access or something. Which makes me think firewall but SELinux and Firewall are disabled.
    – user983223
    Oct 28, 2012 at 13:48
  • Try telnet domain.com 1234. If you get connection refused or a timeout, something is blocking access to that port. Use tcptraceroute (on Windows tracetcp to find out where. If telnet can establish a connection, you should see something in your Apache logs. Oct 28, 2012 at 23:48

4 Answers 4

1

Adding the name/address mapping to your client's hosts file should get you around the name resolution problem in development scenarios. There's also the option to set a wildcard record in DNS if your DNS provider allows it. As soon as the thing goes beyond developer scope I'd strongly recommend setting up proper DNS resolution for it, though.

1
  • I want it to be accessible to the public so I'm trying to avoid the hosts file.
    – user983223
    Oct 27, 2012 at 22:53
1

The ServerName should not include the port number. In your example, just make it "domain.com" for every VirtualHost. ServerName directives do not need to be unique in your situation where you have each VirtualHost on a different port. You also don't need the NameVirtualHost because you're doing virtual hosting by port (although it's not harmful to include).

As a troubleshooting step, make sure IPTables is fully disabled (assuming this is Linux), and verify that by doing "iptables -L -n -v"; look for each table to be empty. You might also make sure SELinux is disabled; see your distro's documentation for how to do that properly, as the procedure varies. If either of those is shown to be the issue, you can either choose to keep them turned off, or configure them correctly to allow Apache to listen on these ports.

Here is an example from the Apache 2.2 documentation about port-based virtual hosting: http://httpd.apache.org/docs/2.2/vhosts/examples.html#ipport

1
  • I fixed the ServerName. I added the NameVirtualHost (even though you said it wasn't required). Iptables each table is empty. Firewall and SELinux are disabled. I'm stumped.
    – user983223
    Oct 27, 2012 at 22:55
0

Is there a firewall like iptables that is blocking it? If so, turn it off or better yet add a rule to allow 1234 through.

1
  • @Michael_Beattie - firewall has been off. Is there a command line to test it? Would it still Listen in the netstat if it was being blocked by the firewall?
    – user983223
    Oct 27, 2012 at 14:05
0

Do you have this directive in your configuration:

NameVirtualHost *:1234

If you don't your VirtualHost will never be used.

1
  • added this but no improvement.
    – user983223
    Oct 27, 2012 at 22:52

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