-1

I'm trying to host 2 different sites on 2 different ports: 80 and 8080. I have currently set this up:

ports.conf

listen 80
listen 8080
NameVirtualHost *:80
NameVirtualHost *:8080

site1.conf

<VirtualHost *:80>
  ServerName my.site
...

site2.conf

<VirtualHost *:8080>
  ServerName a.my.site
...

Portscan tells me port 80 an 8080 are open and both have an http service.

http://my.site works and I get the desired site, but when I'm trying to connect to http://my.site:8080. I get This site can't be reached. my.site refused to connect

What did I do wrong?

(apache 2.2)

EDIT:

http://(ip):8080 works.

I changed site1 site2. Now I tried http://a.my.site and it didn't work. Nor did ... :8080.

  • my.site is not the same as site1 or site2 so it is difficult to understand your question and observations. Stop doing useless obfuscations, with the true names involved people could give you immediate relevant information. And if you obfuscate, please use RFC2606 guidelines to do so. – Patrick Mevzek May 4 '18 at 23:27
0

Did you check your httpd.conf and configure the website root, servername, etc.? (In a default installation, you can find it in /etc/httpd/conf/httpd.conf.)

You can always have different websites with the same port number. Example:

<VirtualHost *:80>
   ServerAdmin admin@site1.com
   DocumentRoot /root/site1
   ServerName site1.com
   ErrorLog logs/site1.com-error_log
   CustomLog logs/site1.com-access_log common
</VirtualHost>
<VirtualHost *:80>
   ServerAdmin admin@site2.com
   DocumentRoot /root/site2
   ServerName site2.com
   ErrorLog logs/site2.com-error_log
   CustomLog logs/site2.com-access_log common
</VirtualHost>

In your case, check that you have configured the proper ports for each site in httpd.conf.

  • Well, There is a httpd.conf file. which is empty. I tried putting in listen 8080, but the it said that 8080 is already in use. – KoneLinx May 4 '18 at 22:54
  • what version of apache are you using? Do you have /etc/apache2/apache2.conf ?? – xJ0ReLx May 4 '18 at 23:27
  • With Apache-2.2 you absolutely need a NameVirtualHost directive in such cases. It became obsolete with 2.3 – Patrick Mevzek May 4 '18 at 23:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.