we need our new dedicated IP address (and all future ones) to "point" to the same root directory of our VPS' "parent" domain (main domain with all business logic, where $_SERVER['host'] is detected to connect associated files etc. )
So, for example, domain.net (x.x.x.146) should show content of domain.com (x.x.x.170) etc
We have list of dedicated IPs, added to WHM. We have number of domain names, with those IPS as DNS A records. We have added those domains via cPanel to point to the same public_html..
But all the domains resolve to : cgi-sys/defaultwebpage.cgi with "SORRY! If you are the owner of this website, please contact your hosting provider:" error.
Any suggestions? This is supposed to be quite an easy task, but clearly - not so.
Thank you
Why do you need many IP address? one IP address should be enough for what you want to do.
Indeed HTTP/1.1 protocol is meant for this purpose: many different domains for one IP.
In your VPS you can use for example "Apache" as a Web server with this basic configuration:
ceate/edit on "/etc/apache2/sites-available/" example.com.conf :
<VirtualHost *:80>
DocumentRoot /home/user/pulic_html
ServerName example.com
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
then create/edit example.org.conf:
<VirtualHost *:80>
ServerName example.org
Redirect permanent / http://example.com/
</VirtualHost>
and so on..
then to enable your configuration :
a2ensite example.com.conf example.org.conf
sudo service apache2 restart
If you still want to use many IPs you can install apache in every machine hosting the IP, then redirect to your main site/domain(http://example.com), as shown above. Otherwise, if your hosting provider allow, you can redirect your children domain to your parent domain from your provider website with GUI.
here is the solution. It is not ideal bot it looks like there's not much we can do, having cPanel/WHM installed.
<VirtualHost x.x.x.x:443>
ServerName domain.net
ServerAlias www.domain.net
DocumentRoot /home/user/public_html
#todo common contact mail
ServerAdmin support#domain.net
UseCanonicalName Off
<IfModule mod_suphp.c>
suPHP_UserGroup user user
</IfModule>
<IfModule ssl_module>
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/domain.net/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.net/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/domain.net/chain.pem
SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown
</IfModule>
<IfModule headers_module>
RequestHeader set X-HTTPS 1
</IfModule>
</VirtualHost>
redirect from 80 to 443 set separately:
RewriteEngine On
RewriteRule ^/?(.*) https://%{SERVER_NAME}/$1 [R,L]
Related
I am trying to allow customers to have multiple domains, but 301 them to their "permanent" domain for canonical reasons. I am getting some strange activity, and am positive it has to do with my syntax, however I don't know where the issue resides.
I have a main domain - let's call it permanent_site.com Note: I have an SSL installed and working for "permanent domain"
I have multiple non-permanent domains that I want to permanently redirect to the "permanent domain". Now lets say I have 2 non primary domains: non_p_domain1.com and non_p_domain2.com.
Should this not work?
<VirtualHost *:443>
ServerName non_p_domain1.com
ServerAlias non_p_domain2.com
Redirect 301 / https://permanent_site.com/
</VirtualHost>
<VirtualHost *:443>
ServerName permanent_site.com
DocumentRoot /path/to/html
SSLEngine on
SSLProtocol all -SSLv2 -SSLv3
SSLHonorCipherOrder on
SSLCertificateFile /path/to/ssl/permanent_site.com.crt
SSLCertificateKeyFile /path/to//ssl/permanent_site.com.key
SSLCertificateChainFile /path/to/ssl/permanent_site.com.ca.crt
</VirtualHost>
The whole point in doing it this way is to prevent someone from hitting https://non_p_domain1.com and being fed an "unsecure page". Instead, I want them redirected to the permanent domain before they hit the html directory that has all the .htaccess directives.
from hitting https://non_p_domain1.com and being fed an "unsecure page"
All the non-primary domains also need to have an SSL cert installed. By the sounds of it, they don't?
If not, then the client won't (or should not) connect to your server, so they never see the redirect.
I've read several posts like mine, but none of them seem to work.
I've got a regular apache config on CentOS 7 with a working website, both HTTP and HTTPS (certbot).
I have another service with a web port of `:3000 and i'd like to have it work as such:
http(s)://example.com (regular website content)
http(s)://example.com/new_site (the service on port 3000)
I've got the website set up as a virtual host with a custom webroot in /var/www/example.com/docroot
This is my current working config. I realized that the connection between the localhost does not need to be HTTPS, just the incoming requests:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
ProxyPass /my_site http://localhost:3000
ProxyPassReverse /my_site http://localhost:3000
ErrorLog /var/log/httpd/my_vhost_log
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
</VirtualHost>
</IfModule>
I also cleared up permissions issues by enabling the httpd_can_network_connect SELinux boolean.
UPDATE:
My issue now is that the above config overwrites my regular website content, so if you go to the https://example.com, it will just show the Apache welcome page, rather than the content in the /var/www/example.com/docroot.
Main config:
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName example.com
ServerAlias www.example.com
DocumentRoot /var/www/example.com/docroot
Include /etc/letsencrypt/options-ssl-apache.conf
SSLCertificateFile /etc/letsencrypt/live/example.com/cert.pem
SSLCertificateKeyFile /etc/letsencrypt/live/example.com/privkey.pem
SSLCertificateChainFile /etc/letsencrypt/live/example.com/chain.pem
</VirtualHost>
</IfModule>
In the event that anyone comes across this,
The fix is simply to add the Proxy lines to your main domain config. You only need a single config file.
I have a site now with address https://example.com/. How to make possible access to this site also by address https://example.com.html? What to write in htaccess?
What to write in htaccess?
Nothing special.
The question is not what to write but what to not write in .htaccess. And the answer is: do not write anything that links the site to one of its names (example.com or example.com.html). The same applies to the PHP source or configuration files.
The rest is just proper names registration, nameserver and Apache configuration.
Regarding the configuration of Apache, let's say the IP address of your web server is 1.2.3.4. The Apache configuration file (httpd.conf f.e.) now contains something similar to this:
<VirtualHost 1.2.3.4:80>
ServerName example.com
DocumentRoot "/www/docs/example.com"
# Other configuration directives for domain example.com
</VirtualHost>
In order to let Apache know the domain example.com.html is the same as example.com you can add a ServerAlias to the <VirtualHost> block:
<VirtualHost 1.2.3.4:80>
ServerName example.com
ServerAlias example.com.html
DocumentRoot "/www/docs/example.com"
# Other configuration directives for domain example.com
</VirtualHost>
Assuming you already have the name and the name servers are properly configured to point to your existing server, restart Apache and it should work.
Read more about <VirtualHost> and ServerAlias
I'm trying to setup my apache server to access certain folders when I type addresses like test1.example.com test2.example.com etc.
So far I read and did many things but with no success yet. I'll be very thankful if you can help me.
So to start I'm using ubuntu 12.10 as my desktop and I've set up apache server there. I've added example.com in hosts resolving to 127.0.0.1. So far no problems. I've enable vhost_alias and mod_rewrite in apache and I'm using this for my virtual server
NameVirtualHost *:80
UseCanonicalName Off
<VirtualHost *:80>
ServerName example.com
ServerAlias *.example.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?([^\.]+).example.com$
RewriteRule ^(.*) $1 [F]
VirtualDocumentRoot /home/example/server/projects/%1/public_html
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /home/radoslav/server/projects>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
#log file for this server
CustomLog /var/log/apache2/example.com.log combined
</VirtualHost>
But when I open test.example.com it says that browser can find test.example.com, no matter that I have this directory in the path specified. Just to clear things up apache have permissions to read this directory so it's not this. When I ping example.com from console I get ping but if I ping test.example.com I get error that can not find host. As you can see obviously it's not resolving the adress no matter that I've setup everything correcly.
Any help guys?
You need to add test.example.com and any other hostnames you want to use in the host file. The host file does not supports wildcard.
I have recently just set up a RHEL based server running two domains. However, I am having difficulty hitting both domains from the browser. My config is:
NameVirtualHost *:80
<VirtualHost *:80>
ServerName domainA.com
ServerAlias domainA.com *.domainA.com
DocumentRoot /home/domainA/public_html
<Directory "/home/domainA/public_html">
allow from all
Options +Indexes
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName domainB.com
ServerAlias domainB.com *.domainB.com
DocumentRoot /home/domainB/public_html
<Directory "/home/domainB/public_html">
allow from all
Options +Indexes
</Directory>
</VirtualHost>
The problem is when I navigate to domainA.com I hit the correct Virtualhost (which is fine), however when I navigate to domainB.com it displays the Apache Test page.
Edit
I have a Firewall between the webserver and the web. I tested the rules governing Domain A and Domain B.
Domain A reaches target and a status 200 is returned.
Domain B reaches target and a status 403 (permission denied) is returned
What you need to do is take a look at sites-enabled and sites-available.
Here's the first entry when Googling: http://www.debian-administration.org/articles/412
Looks reasonable and should help you integrate that.
The problem is that you need separate entries for all the sites you want to run on this apache2. Simple entries in your config file don't do it. Only the first works, the rest is more or less ignored. Creating separate entries with sites-enabled and sites-available is the way to go here.