1

I have a strange behaviour on my VPS that I cannot explain.

My server is a Lucid Lynx. Apache version is 2.2.14

I wanted to make some requests to localhost faster, so I added an extra line in my /etc/hosts file:

127.0.0.1 example.com # example.com is currently hosted on the same instance.

I restarted apache2, and after an hour of debugging I found that my server answers correctly to any https calls on 443 port when they are coming from a remote source, but tries to communicate with simple http, when I'm trying from it's own console.

Removing the alias from /etc/hosts and restarting apache2 fixes the problem.

Is there a common misconfiguration somewhere that can cause this behavior?

3
  • Executing wget https://mydomain.com/ on the console causes a redirect to http://mydomain.com/ ? Aug 29, 2012 at 16:21
  • Please update your question with the output of curl -I https://example.com/ Aug 29, 2012 at 16:51
  • How exactly is your HTTPS virtual host defined? What exactly do you have in the <VirtualHost ...> line in your config?
    – Zoredache
    Aug 29, 2012 at 17:41

2 Answers 2

2

Making your hostname resolve to 127.0.0.1 used to be explicitly discouraged, for causing problem with "stupid programs". Connecting to a local IP should be fast regardless of using the loopback interface or not.

If removing the alias solves the problem, just do it.

1
  • That's right. I did not know that, but I just have tested it. Thank you.
    – mimrock
    Aug 30, 2012 at 8:21
0

a) you dont need to restart apache after changing your /etc/hosts b) are you changing /etc/hosts and apache running off of same host? c) show us your apache's configuration

apache doesn't really listening on 127.0.0.1, so what you did seems wrong (to me at least)

[root@wcmisdlin02 ~]# netstat -tanpv | grep httpd
tcp        0      0 :::80                       :::*                        LISTEN      12428/httpd         
tcp        0      0 :::443                      :::*                        LISTEN      12428/httpd         
[root@wcmisdlin02 ~]# 

I think main thing is that your https virtual host is binded to a specific IP and you're trying to reach to it through different IP so that's where it brakes...

You must log in to answer this question.

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