0

I am using Apache as a proxy server for my web application wich is running in a Glassfish container. I configured the proxy pass and also SSL in Apache. The site can be accessed from outside with the URL https://www.my-domain.com without any problem. But I want to call the site without prefix "https://" ( www.mydomain.com. )on the browser.

If I use URL without https:// it gives me the error "cannot connected to the server " on browsers (Safari, firefox ) and using curl on command prompt it says:

Rebuilt URL to: www.my-domain.com/
Trying 2xx.xxx.xxx.xxx...
connect to 2xx.xxx.xxx.xxx port 80 failed: Connection refused

I configured virtual host according to the apache documentation to redirect any request without "https" to "https". Hier is my configuration :

<VirtualHost 2xx.xxx.xxx.xxx:80> 
ServerName my-domain.com
ServerAlias www.my-domain.com
RewriteEngine On
RewriteCond %{HTTPS} !=on 
RewriteRule (.*) https://my-domain.com [R,L]
</VirtualHost>

Is there anything that I am missing with the configuration? Why the Apache server not redirect the request ? any help would be highly appreciated.

ps. once I call the page with https:// from outside, It can be called even with cash deleted , without prefix https://. In the VPN or in same network it works without the prefix.

Lakshi
  • 101
  • 2
  • If it's getting a connection refused, then apache can't even see the request to redirect it. You need to solve why the connection is refused. Did you restart apache after making these changes? Have you checked the logs for errors? Did you configure your firewall to allow connections to port 80? –  Aug 10 '17 at 20:06
  • Also, your title says 'without http://'. I think you meant without https://. I suspect you'll get the exact same response with or without http://. –  Aug 10 '17 at 20:08
  • yes I did. usually i restart the server sudo service apache2 restart – Lakshi Aug 10 '17 at 20:09
  • check your firewall rule please, or the router port forward on the 80. The fact it give you a connection refused talk by itselft, an close port would throw a unable to connect exception, not refused. – yagmoth555 Aug 10 '17 at 23:05

1 Answers1

1

You need to ensure you have a valid Listen statement for port 80 in your apache config. Simply adding a port 80 virtual host is not enough.

mikea
  • 11
  • 1
  • well if I don't have a valid Listen statement how can it then get work with https:// prefix ? – Lakshi Aug 10 '17 at 20:11
  • 1
    Because https is port 443, not port 80. –  Aug 10 '17 at 20:11
  • @yoonix I can call the site without https:// inside the same network or better say in VPN – Lakshi Aug 10 '17 at 20:14
  • then I'd go back to my original question about the firewall. The two options are: 1) Apache is not configured to listen on 80. 2) A firewall is blocking the traffic. If it works on 80 on the local network, then it would be a pretty strong indicator your problem is #2. –  Aug 10 '17 at 20:15
  • with the firewall I have to check again. But the other thing is if I call the page with once with with https:// prefix , then I can call it again without the prefix . how can that happen ? – Lakshi Aug 10 '17 at 20:17
  • You should spend the time to answer that question yourself using standard troubleshooting techniques. This is a site for professionals afterall. –  Aug 10 '17 at 20:46
  • @mikea Port 80 is already enabled. To make sure I added it to virtual host config file inside sites-available. but no effect. – Lakshi Aug 10 '17 at 21:16
  • Professionals who have access to the system will run troubleshooting procedures over there. Because we don't have access to your system for troubleshooting, doesn't make us non-professionals. – Tero Kilkanen Aug 10 '17 at 21:24
  • I did troubleshooting , I inspected the logs. but nothing I can figure it out. inside the same network it works fine. The port 80 is enabled. does that make some one unprofessional ? – Lakshi Aug 10 '17 at 21:32