0

I am trying to setup a local network and I am using these kind of types of network.

  1. Main server which connects to internet with static IP
  2. Second computer connected to first one locally with address like 192.168.0.2 - when I write this address to address line it is like i wrote localhost in original main server - so it should show my local web browser etc ...

It has domain name this IP and connected router for it ... example www.domain.com so I added to my main server hosts file (linux powered) lines like these:

192.168.0.2 domain.com www.domain.com

It was working ok when I entered my domain name in local computer it showed my site ... But after some time I added HTTPS cerfiticate and added this line to my apatche server:

Redirect permanent / https://www.domain.com/

And now it does not work even when i add something like this to my hosts file:

192.168.0.2 https://www.domain.com

So any idea how do do this thing work? Thank you.

8
  • 2
    2 hour penalty for "does not work". Jun 4, 2012 at 0:52
  • You don't specify a protocol in a hosts file (or DNS A record)
    – MDMarra
    Jun 4, 2012 at 0:53
  • @IgnacioVazquez-Abrams - I do not see any difference between "does not work" and for example "adding https broke my settings" etc it is metter of speech ...
    – Byakugan
    Jun 4, 2012 at 1:00
  • @MDMarra When I do not specify it why is that redirecting causing trouble now?
    – Byakugan
    Jun 4, 2012 at 1:00
  • 2
    If you can't tell the difference between "cause" and "effect" then.... I don't know what to tell you. Jun 4, 2012 at 1:11

1 Answer 1

3

Hosts files for dummies. DNS doesn't give a rip about protocols, it's only there to translate numbers to human readable names. (well mostly true) So revert your hosts file line back to:

192.168.0.2 domain.com www.domain.com

The question is mostly incomplete as you don't explain why a redirect was necessary or if you properly set up your Apache server to accept SSL/TLS connections. I'd vote that the server hasn't been set up to accept port 443 traffic properly and the redirect is sending the traffic to an unresponsive or non-existent HTTPS port.

Since this is a question about a home network, the question will probably be closed as not appropriate to ServerFault.

If your redirect was supposed to change insecure connections to secure connections, the more appropriate way is to test the connection and switch it.

#####################################################
# Control access to php app, secure only

Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTPS} !=on
RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [R,L]

I'd recommend dumping the redirect for the nonce and work on getting the server to respond on both HTTP port 80 and HTTPS port 443 with the certificate properly installed. SSL/TLS Strong Encryption: FAQ

Only once you have this working would I recommend trying to direct all the traffic to HTTPS.

7
  • SSl is installed corectly - my point was to have always https on all web no metter what.
    – Byakugan
    Jun 4, 2012 at 2:05
  • Do you have your hosts file cleaned up so it's not trying to force in an unwanted parameter that will keep the name from resolving to the IP address? So, when you remove the redirect, you can get in on HTTP and HTTPS? Correct? Jun 4, 2012 at 3:13
  • That is correct :)
    – Byakugan
    Jun 4, 2012 at 10:42
  • Ok, if you put the redirect to HTTPS back in, does the site now fail? If so, check your web server error logs, there is probably a line giving you a specific message as to why the server cannot be contacted. You need to enable certain modules for things to work. Your original line, Redirect permanent / https://www.domain.com/ if letter perfect, requires mod_alias.so to run. My version that checks to see how it was accessed (HTTP or HTTPS and then rewrite if HTTP) requires mod_rewrite.so to be loaded. httpd.apache.org/docs/2.4/mod/mod_so.html#loadmodule Jun 4, 2012 at 15:04
  • Actually I have it all working meaning that it is working as https with redirect BUT it is not working on localhost ... If I want to use in my local computers domain name instead of localhost that is my problem from the begining :) outside it is working perfectly but on localhost it is working only without https (redirect)
    – Byakugan
    Jun 4, 2012 at 15:21

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