Apache questions.

Posted:
in Genius Bar edited January 2014
I'm trying to configure my Apache to get virtual hosts working properly. I've tried reading the docs, but I swear they might as well be written in a different language.



My requirements at this time are fairly simple:



Have different document roots for my various subdomains. I'd like webmail.psyresearch.com to go to my Squirrelmail directory automatically, for example. Easy enough, right?



Now for my second question: I'd like to be able to redirect automatically to my secure server. So if someone types in www.psyresearch.com , I'd like them to be automatically redirected to https://www.psyresearch.com . Again, simple enough, but I can't figure out how to do it.



Any help would be greatly appreciated.



-t

Comments

  • Reply 1 of 5
    http://apache.org/



    http://httpd.apache.org/docs/



    The only thing I can do is refer you to this site. If it were me helping you with that, I think I'd have to be there with you.



    By the way, this site is SOMETIMES very useful.



    -walloo.
  • Reply 2 of 5
    torifiletorifile Posts: 4,024member
    Quote:

    Originally posted by willywalloo

    http://apache.org/



    http://httpd.apache.org/docs/



    The only thing I can do is refer you to this site. If it were me helping you with that, I think I'd have to be there with you.



    By the way, this site is SOMETIMES very useful.



    -walloo.




    Thanks for that. Now, do you have a real answer to my questions?
  • Reply 3 of 5
    I used to have a OS X server set up which used Virtual Hosts - but it has been a couple years. It was really pretty simple to do at the time, but I have forgotten most of everything. I dug back through my old httpd.conf to see what I did - and it looks totally simple, so maybe we could walk through it together...



    Here is a pertinent part of the conf file (I had 6 or so domains, this is just the first one):



    Code:




    #

    # Use name-based virtual hosting.

    #

    #NameVirtualHost *



    #

    # VirtualHost example:

    # Almost any Apache directive may go into a VirtualHost container.

    # The first VirtualHost section is used for requests without a known

    # server name.

    #

    #<VirtualHost *>

    # ServerAdmin [email protected]

    # DocumentRoot /www/docs/dummy-host.example.com

    # ServerName dummy-host.example.com

    # ErrorLog logs/dummy-host.example.com-error_log

    # CustomLog logs/dummy-host.example.com-access_log common

    #</VirtualHost>



    #Include /private/etc/httpd/users

    NameVirtualHost 192.168.1.101



    <VirtualHost 192.168.1.101>

    DocumentRoot /Volumes/WebSpice/WebServer/Documents/imagemason

    ServerName imagemason.com

    </VirtualHost>



    <VirtualHost 192.168.1.101>

    DocumentRoot /Volumes/WebSpice/WebServer/Documents/webmail

    ServerName mail.imagemason.com

    </VirtualHost>









    I don't have any experience with secure servers (https) so I am not sure about that one - but the above might help for redirection of other things. That NameVirtualHost is obviously behind a firewall - if you are using your server as the firewall, give it your actual static IP. Also, of course, make sure all the domain names point to your server IP. If, on the other hand, you want to use IP based virtual hosts all on the same machine, that is configure a little bit above the quoted section of code... I never set that up myself, but it looks to be similar.



    One hack you could use to get to https:// is just use PHP (or even a meta refresh). PHP would be:

    Code:




    header('Location: https://www.yourdomain.com');









    Let me know if that helps with anything...
  • Reply 4 of 5
    Quote:

    Originally posted by torifile

    Thanks for that. Now, do you have a real answer to my questions?



    NOPE !



    Well, this area is one I need to study more on. But I didn't get your question in the first place, so maybe it's that.



    So, you want a virtual domain to point to a folder, is that right? (goin one part at a time!?)



    (sorry),

    -walloo.
  • Reply 5 of 5
    torifiletorifile Posts: 4,024member
    Quote:

    Originally posted by willywalloo

    NOPE !



    Well, this area is one I need to study more on. But I didn't get your question in the first place, so maybe it's that.



    So, you want a virtual domain to point to a folder, is that right? (goin one part at a time!?)



    (sorry),

    -walloo.




    The Pie Man sort of answered my question. It seems to work just fine for http:// sites but not at all for https:// sites. Looks like more reading is required. :/ Oh well, I've got a project for the weekend.



    It's not actually a virtual domain I'm looking to mess with. It's a subdomain of my main domain. Nothing too complicated...
Sign In or Register to comment.