So here's the scenario:
The domain I have is www.abc.com and I want to point it to (which belongs to another company).
Question: How would I use .htaccess to forward and mask the url so that it stays as www.abc.com?
In terms of security, is there any point in buying a digital certificate for www.abc.com?
You could uh, run it through a proxy, which will TOTALLY mask it.
You put this in your httpd.conf file, not the .htaccess:
<VirtualHost *:80>
ServerName www.abc.com
ServerAlias abc.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://site-you-want-2-show.com:80/
ProxyPassReverse / http://site-you-want-2-show.com:80/
<Location />
Allow from all
</Location>
</VirtualHost>
You can try with ProxyPreserveHost both On and Off, and testing if the images display properly and the addresses of objects show your domain instead.
WARNING: This is not legal if you do not have explicit permission from the company you are trying to show's website. Perhaps you can then just make your homepage an iFrame.
As for certificates: It can be done, see here: http://ssl-proxy.plz.re (short-url)
.htaccess files cannot "mask" a domain but could use a reverse proxy if the module is installed.
In most case, the "masked" website will refer to full urls and the "mask" will not work for long.
See what #mesh proposed.
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.
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]
I'm just trying to point my apache server at a node.js app by changing the virtual host settings to use proxy settings and when I try to make the Block match all locations via It matches only urls with 1 level deep url paths. /example works but /example/damn does not work. So I tried changing the regex to Which is even overkill but I thought I'd try it, I've been trying a lot of other regex combinations but none capture the URLs. I might add that this regex above actually doesn't capture anything AT ALL, it just shows the index list for my site when I got the url. The only regex that works at all is "/*" but it doesn't go deeper than 1 url /path/anotherpath
I checked that my regex should be matching everything at https://regex101.com/ But still apache isn't capturing it.
here's me config
<VirtualHost *:80>
ServerName my.dev
ServerAdmin ireply#myleisure.com.au
DocumentRoot /home/ggg/Dropbox/host-root/var/www/myleisure.com.au
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Full
<Proxy "*">
Require all granted
</Proxy>
<Location "(.*)*">
ProxyPass http://localhost:3000
ProxyPassReverse http://localhost:3000
</Location>
</VirtualHost>
Here is quote from Apache directive configuration documentation page
The directive limits the scope of the enclosed
directives by URL, in an identical manner to . However, it
takes a regular expression as an argument instead of a simple string.
Therefore, try using:
<LocationMatch "(.*)*">
ProxyPass http://localhost:3000
ProxyPassReverse http://localhost:3000
</LocationMatch>
I currently have example.com pointing to Server one. I wanted to server example.com from a different directory ( /WebData )
I did this by editing httpd.conf
http://pastebin.com/UjHhRNTX
I this works as desired.
I then found out I needed to add website.org to the server. So I mounted another disk and created a dir called /WebDataWebsite
and created /etc/httpd/conf.d/websiteorg.conf with the following VHost:
http://pastebin.com/GTmqtABf
<VirtualHost *:80>
DocumentRoot "/WebDataWebsite"
ServerName website.org
ServerAlias www.website.org
<Directory "/WebDataWebsite">
Require all granted
</Directory>
</VirtualHost>
For some reason all traffic to example.com and website.org were both directed to index.htm in /WebDataWebsite
What I am doing wrong? How to I make /WebData (in httpd.conf) the default website but filter by servername website.org with the VHost?
You'll probably need to use Alias's for the second site. Have a look at http://httpd.apache.org/docs/2.2/mod/mod_alias.html#alias
It's unlikely that second declaration of the VH is being picked up by apache as it can not deal with two declarations of the same I believe.
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.