CentOS7 - Apache Virtual Hosts
-
While I look up how to do that.... why?
-
Do I need to setup a virtual host for the IP address?
-
@scottalanmiller said:
While I look up how to do that.... why?
Because I don't want Google finding the IP address, and using it for search results.
-
@Aaron-Studer said:
Do I need to setup a virtual host for the IP address?
Yes, when all blocks fail, Apache chooses the first block. So create a block that goes to the Apache page with no other settings and make it first.
-
@Aaron-Studer said:
@scottalanmiller said:
While I look up how to do that.... why?
Because I don't want Google finding the IP address, and using it for search results.
Have you ever seen that happen?
-
-
@scottalanmiller said:
Yes, when all blocks fail, Apache chooses the first block. So create a block that goes to the Apache page with no other settings and make it first.
I am confused. I thought I create a conf file for each site? What your saying, sounds like one conf file for all sites?
Using this guide if it matters: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-centos-7
-
Look for:
VirtualHost _default_:80
That's likely what's being triggered, if that doesn't exist, it often will fall back to the main default page
-
@Aaron-Studer said:
@scottalanmiller said:
Yes, when all blocks fail, Apache chooses the first block. So create a block that goes to the Apache page with no other settings and make it first.
I am confused. I thought I create a conf file for each site? What your saying, sounds like one conf file for all sites?
Using this guide if it matters: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-centos-7
You can, but it's a pain to manage. I usually just have a single configuration file. The only real reason to have multiple files is if you do a lot of editing, very often of them.
-
@Aaron-Studer said:
@scottalanmiller said:
Have you ever seen that happen?
No, but I could see it happening.
Why is that an issue? it's not like you are really hiding anything or protecting anything like that.
-
I would just prefer if it went to the default page.
-
@Aaron-Studer said:
I would just prefer if it went to the default page.
you are giving much more information away about the server that way.
-
From a "just in case" perspective it's good to have something if the virtual host either does not exist or someone goes right to the IP. We set both the default:80 virtual host and the regular default page to this, and it's not an issue, though as I said, I'd check your virtual hosts if regular default page is not working.
-
@Aaron-Studer said:
@scottalanmiller said:
Have you ever seen that happen?
No, but I could see it happening.
That's not a good reason to do this. Google definitely doesn't do that. That you could "see programmers screwing things up on a global scale but they never have and they would fix it if they did" isn't a good reason to do weird things.
-
@Aaron-Studer said:
@scottalanmiller said:
Yes, when all blocks fail, Apache chooses the first block. So create a block that goes to the Apache page with no other settings and make it first.
I am confused. I thought I create a conf file for each site? What your saying, sounds like one conf file for all sites?
Using this guide if it matters: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-centos-7
Whether you make one or many, they get turned into one before being used. That they are separate files to you is purely for you.
-
@tonyshowoff said:
@Aaron-Studer said:
@scottalanmiller said:
Yes, when all blocks fail, Apache chooses the first block. So create a block that goes to the Apache page with no other settings and make it first.
I am confused. I thought I create a conf file for each site? What your saying, sounds like one conf file for all sites?
Using this guide if it matters: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-centos-7
You can, but it's a pain to manage. I usually just have a single configuration file. The only real reason to have multiple files is if you do a lot of editing, very often of them.
Yup, I normally just use one. Maybe if you have thousands of sites.
-
@Aaron-Studer said:
I would just prefer if it went to the default page.
That's a bizarre preference. This falls under what I call "being weird." Why are you the only person who wants to do this? Why does no other company or person want this? It's your person machine, you can do what you want, but you are being weird here. I don't know how else to describe it. As a personal site, whatever. But if this was a business, someone should be demanding that you provide logic for deviating from accepted behaviour. What's your goal here? You just really love advertising your information about your platform and looking like you made a mistake?
-
Can someone give me an example or guide with one conf file?
-
@Aaron-Studer said:
Can someone give me an example or guide with one conf file?
There is nothing to know, really. You just tack the configuration on to the end of the httpd.conf file. Single file is the CentOS default. You need no guide, just edit the file.
-
@Aaron-Studer said:
Can someone give me an example or guide with one conf file?
You just put it all together, modules first, basic config (for modules) after that, default document stuff/base document configuration and security configuration, then at the end virtual hosts. That's the most common way. All you really need to do is go through your main config file and see where it references other files, and put the content of those files where the old include was.