Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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?

share|improve this question
    
Executing wget https://mydomain.com/ on the console causes a redirect to http://mydomain.com/ ? –  Mark Wagner Aug 29 '12 at 16:21
    
Please update your question with the output of curl -I https://example.com/ –  Dave Forgac Aug 29 '12 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 '12 at 17:41

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer
    
That's right. I did not know that, but I just have tested it. Thank you. –  mimrock Aug 30 '12 at 8:21

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...

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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