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 am trying to do 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.

share|improve this question
    
2 hour penalty for "does not work". –  Ignacio Vazquez-Abrams Jun 4 '12 at 0:52
    
You don't specify a protocol in a hosts file (or DNS A record) –  MDMarra Jun 4 '12 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 '12 at 1:00
    
@MDMarra When I do not specify it why is that redirecting causing trouble now? –  Byakugan Jun 4 '12 at 1:00
1  
If you can't tell the difference between "cause" and "effect" then.... I don't know what to tell you. –  Ignacio Vazquez-Abrams Jun 4 '12 at 1:11
show 3 more comments

1 Answer

up vote 3 down vote accepted

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.

share|improve this answer
    
SSl is installed corectly - my point was to have always https on all web no metter what. –  Byakugan Jun 4 '12 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? –  Fiasco Labs Jun 4 '12 at 3:13
    
That is correct :) –  Byakugan Jun 4 '12 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 –  Fiasco Labs Jun 4 '12 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 '12 at 15:21
show 2 more comments

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.