LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 05-15-2019, 11:50 AM   #1
witchkinkofangmar
LQ Newbie
 
Registered: May 2019
Posts: 13

Rep: Reputation: Disabled
Internal VM development web server running CentOS7 with multiple site directories in /var/www/html setup


I have an internal development vm server people will use to test their site’s code.

In the /var/www/html/ directory, there are about 15 site directories mounted from a SAN. None of this will be accessible externally.

How do you redirect to those directories on one server with one IP?

Should I create A records for all the internal sites so they have their own and attach a virtual nic for each one?

Or should I use .htaccess or httpd.conf to redirect somehow? New to this so any advice or links on how this is done is good. I’m not sure how to phrase searches and can’t find much on my own.

—thanks
 
Old 05-15-2019, 11:59 AM   #2
smallpond
Senior Member
 
Registered: Feb 2011
Location: Massachusetts, USA
Distribution: CentOS 6 & 7
Posts: 3,159

Rep: Reputation: 844Reputation: 844Reputation: 844Reputation: 844Reputation: 844Reputation: 844Reputation: 844
Apache can serve multiple sites from one IP using the hostname in the URL. In that case, the clients need to send a hostname in the URL, so you will need your local DNS to point all of the sites to one IP. If you want to do HTTPS its a little more work, because you need a properly configured certificate for each site.

https://opensource.com/article/18/3/...b-sites-apache
 
1 members found this post helpful.
Old 05-15-2019, 12:18 PM   #3
witchkinkofangmar
LQ Newbie
 
Registered: May 2019
Posts: 13

Original Poster
Rep: Reputation: Disabled
Nice, so I need to add a virtual host config for each site in httpd.conf it looks like.

<VirtualHost *:80>
DocumentRoot /var/www/html/site1
ServerName www.site1.org
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /var/www/html/site2
ServerName www.site2.org
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /var/www/html/site3
Servername www.site3.org

</VirtualHost>

Last edited by witchkinkofangmar; 05-15-2019 at 03:56 PM.
 
Old 05-15-2019, 04:17 PM   #4
witchkinkofangmar
LQ Newbie
 
Registered: May 2019
Posts: 13

Original Poster
Rep: Reputation: Disabled
This works great for sites on the server itself, but only the main directory at /var/www/html is available outside the server.

If I go to the other sites on a different machine on the same network, I can only access them if I update my /etc/hosts file

mysite.org works, which is actually the VMs name
mysite2.org doesn't except on VM
mysite3.org doesn't except on VM

Is there something that can be done without assigning different ports that users would have to attach to the name or updating the users hosts file? I'd like to avoid them having to add the port.
...
<VirtualHost *:81>
DocumentRoot /var/www/html/site2
ServerName site2.org:81
</VirtualHost>
...
mysite.org
mysite2.org:81
mysite3.org:82

Last edited by witchkinkofangmar; 05-15-2019 at 04:28 PM.
 
Old 05-15-2019, 05:44 PM   #5
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,053

Rep: Reputation: 1067Reputation: 1067Reputation: 1067Reputation: 1067Reputation: 1067Reputation: 1067Reputation: 1067Reputation: 1067
This may not be the issue, but...if you define ServerName as www.site1.org apache won't know from just site.org.
Add a ServerAlias directive to the VirtualHost
Code:
ServerAlias site.org
No, you do not need to (and shouldn't) use multiple ports. We serve a couple hundred domains on port 80...but only by name, of course.

As smallpond said.
Quote:
you will need your local DNS to point all of the sites to one IP
Alternatively, you can match the domain name to IP address in the remote 'puter's /etc/hosts, which you say works.

You have to do something to point users to the IP address by name...either DNS or /etc/hosts.
 
1 members found this post helpful.
Old 05-16-2019, 11:26 AM   #6
witchkinkofangmar
LQ Newbie
 
Registered: May 2019
Posts: 13

Original Poster
Rep: Reputation: Disabled
I was able to add an A record on that IP to get site2 and site3 working. I did also add a ServerAlias for them.

I did this yesterday as well (not the server alias), and it didn't seem to work but after about 10-15 minutes, it did. I guess it just took a while to propagate and I wasn't patient enough.

Thanks for all the help!
 
1 members found this post helpful.
Old 05-16-2019, 04:39 PM   #7
scasey
Senior Member
 
Registered: Feb 2013
Location: Tucson, AZ, USA
Distribution: CentOS 7.6
Posts: 3,053

Rep: Reputation: 1067Reputation: 1067Reputation: 1067Reputation: 1067Reputation: 1067Reputation: 1067Reputation: 1067Reputation: 1067
Quote:
Originally Posted by witchkinkofangmar View Post
I was able to add an A record on that IP to get site2 and site3 working. I did also add a ServerAlias for them.

I did this yesterday as well (not the server alias), and it didn't seem to work but after about 10-15 minutes, it did. I guess it just took a while to propagate and I wasn't patient enough.

Thanks for all the help!
Glad you got it working. You can mark your thread SOLVED using the thread tools, if you want.

Yes, it can take time for changes like that to propagate. I'm on Cox at home, and changes to DNS can take up to 30 minutes to be seen on my home desktops, although 5-10 minutes is the norm.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Internal VM development web server running CentOS7 with multiple site directories in /var/www/html setup witchkinkofangmar Linux - Server 1 05-15-2019 02:19 PM
block particular web site form multiple site hosted web server and allow others lasantha Linux - Security 2 08-17-2010 01:49 PM
block particular web site form multiple site hosted web server and allow others lasantha Linux - Security 1 08-17-2010 12:09 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:45 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration