TransWikia.com

Apache vhost local request

Unix & Linux Asked by rumburak on January 29, 2021

I got 2 sites configured via apache vhost like:

<VirtualHost *:443>
    DocumentRoot /var/www/site1
    ServerName  www.site1.com
...
    
<VirtualHost *:443>
    DocumentRoot /var/www/site2
    ServerName  www.site2.com
...

I would like to know how to make a request to those sites locally from the server that is running apache. I can connect to the server via SSH and then I would like to do for example wget. When I use for example www.site1.com domain as a request then it goes outside to the Internet and then it comes back to the server. I would like to check the site just locally without the request going outside the server. I guess I can use local IP address to get the response from the first site, but I do not know how to access the other one.

2 Answers

You can edit /etc/hosts or you should use curl with option resolve.

Answered by lbor on January 29, 2021

If Apache is listing on all interfaces (which it is by default), you can just add the host names to /etc/hosts file and access them via the loop back interface.

#/etc/hosts
...

127.0.0.1 www.site1.com www.site2.com

...

Then try from the server terminal to access is via wget or curl

$ curl -Iv https://www.site1.com

Answered by Rabin on January 29, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP