Apache Default Proxy - apache

I have an internal web server (192.168.1.2) that manage multiple domains.
Now i need to put in DMZ one more server, acting as reverse proxy (it's an Apache 2.2.3, with IP 192.168.1.3 and one more interface with static internet IP)
I need this Apache server should proxy any domain coming from internet to my internal web server except for one domain (this.example.com)
A sort of schema:
INTERNET->Apache Proxy->Internal Web server (default for any domain)
INTERNET->Apache Proxy->Differente Web Server (this.example.com)
What kind of configuration do i have to setup on this Apache Proxy? I read about Proxypass and similar string, but i didn't understand how to proxy "the default" to my internal web server...
Thank you for your help

This is working on "defaults", but domain this.example.com does not work...
NameVirtualHost *:80
<VirtualHost *:80>
RewriteEngine On
RewriteRule ^(.*)$ http://192.168.1.2$1 [P]
</VirtualHost>
<VirtualHost *:80>
LogLevel warn
ServerName this.example.com
DocumentRoot /var/www/html
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/html/>
Options Indexes FollowSymLinks MultiViews
#AllowOverride None
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>

Related

WAMP Server will not allow access to website using "www"

I cannot access my website using "www" before domain name but I can if I don't use the "www". I would like to have both accessible.
I am very familiar using Apache2 Server on Linux but it's not often I have to use it alongside WAMP. I have done plenty of messing around in the config files and have tried a few different methods but nothing seems to be working.
Here is the httpd-vhosts.conf file:
# Virtual Hosts
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName wherehousemke.com
DocumentRoot "c:/wamp64/www/wherehousemke"
<Directory "c:/wamp64/www/wherehousemke/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
Require all granted
</Directory>
</VirtualHost>
The website that I am trying to get this to work for is http://wherehousemke.com. That URL is working but if you add "www" in there It will NOT work.
you need to add a DNS record that redirects from your TLD to the www subdomain https://www.digitalocean.com/community/questions/using-cname-for-www-redirection

How apache2 can deny connections to a domain which is not hosted

I am hosting website iplocation.io on a cloud server. I found a domain https://chrissloey.com/index.php which opens my website within it.
Now from what I understand, chrissloey.com has pointed it A record to my server ip and my apache2 server is not denying connection to it and allow's to open iplocation.io website content like its own.
I want apache2 to deny connections to any other domain and only allow my own domain to server content.
Attached is apache conf file for iplocation.io
<VirtualHost *:80>
ServerAdmin email#email.com
DocumentRoot /var/www/public_html
ServerName iplocation.io
ServerAlias www.iplocation.io
ErrorLog ${APACHE_LOG_DIR}/apache-error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<Directory /var/www/public_html>
Options FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
<IfModule mod_ssl.c>
<VirtualHost *:443>
ServerName iplocation.io
ServerAdmin email#email.com
DocumentRoot /var/www/public_html
SSLEngine on
SSLCertificateFile /path-to-csr
SSLCertificateKeyFile /path-to-key
SSLCertificateChainFile /path-to-ca
<Directory /var/www/public_html>
Options FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
</VirtualHost>
</IfModule
Looking at the two comments I think the combination makes most sense:
Configure httpd to respond with redirect (301) to all incoming requests. This could be done on the 'root' host.
Configure a virtualhost listening to your domain only, and this one would serve your real content only.
This will work unless the other site requests your content and then integrates it into their responses. But as you said someone else simply put up a DNS A record.

Proxying between tomcat and apache

I have apache2 and tomcat7 in /var/lib/tomcat7. I have my two apps in tomcat webapps: app1 and app2. I have configured my apache virtual host as below:
#
<VirtualHost *:80>
ServerName myweb1.com
ProxyRequests Off
ProxyPass / http://localhost:8080/web1/
ProxyPassReverse / http://localhost:8080/web1/
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
#
myweb1.com is running in a browser but when I make another vhost for web2, myweb2.com is not loading. Yet when I do myweb2:8080/web2 in my browser it's loading the page. What could be the reason for this? Note that myweb2.com has no problem with DNS entry.
I have tried to put web2 into /opt/tomcat9/webapps but the same results come.

How to forward 80 port to 2 server based on donain

I have 2 apache server connected to a router. From the router settings, I can forward 80 and 443 port to a single machine/internal IP. Then I can access to it from my external IP address. My domain has A record pointed to that IP address. So, I am able to access to that machine using my domain.
But I want to use my both apache server for two different domain. Suppose, domain1.com will be connected to server1 and domain2.com will be connected to server2.
Is there any way to do this?
If you got a single server with two websites and two domains you can simply create two VirtualHost blocks in your vhost config file. Both might look similar to each other but you have to change the DocumentRoot and the ServerName entry.
The file will look similar to the following:
<VirtualHost *:80>
DocumentRoot "/var/www/Website1"
ServerName Website1.com
<Directory "/var/www/Website1/public">
Options Indexes FollowSymLinks MultiViews Includes ExecCGI
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "/var/www/Website2"
ServerName Website2.com
<Directory "/var/www/Website2/public">
Options Indexes FollowSymLinks MultiViews Includes ExecCGI
DirectoryIndex index.php
AllowOverride All
Order allow,deny
Allow from all
Require all granted
</Directory>
</VirtualHost>
For sure you can also handle an https connection within this file.
Additionaly there are good ways of handlign the connection redirects with an .htaccess file in the desired root folder.

apache virtual host redirect traffic works in LAN but not WAN

I have a domain hosted by yahoo.
But i am using my own in house server to actually host my Domain and cloud sub domain.
so in the Yahoo, i forward all www.mydomain.com to my static ip
<meta http-equiv="refresh" content="0; url=http://111.111.111.111">
and all my sub-domain traffic to my static ip:
<meta http-equiv="refresh" content="0;URL=http://111.111.111.111/cloud" />
My in-house server is Apache 2.4.7 on Ubuntu 14.04LTS. I have created a virtual host site and enabled it and it works very well as long as i am in the LAN. When i am on the WAN, however, the web browser times out saying that the server stopped working.
I think i know where the problem is, but i am not sure how to solve it, namely in the redirect to the htpps - i am using a LAN IP. Using my static IP or my domain name did not help me solve this. here is my enabled site for my virtual host:
<VirtualHost *:80>
ServerAdmin admin#myexample.com
ServerName www.myexample.com
ServerAlias myexample.com
DocumentRoot /var/www/html/example-test/
Alias / /var/www/html/example-test/
### Redirect /cloud https://www.myexample.com/cloud
Redirect /cloud https://192.168.1.122/cloud
### Redirect /cloud https://111.111.111.111/cloud
<Directory /var/www/html/example-test>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
<Directory /var/www/owncloud>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache_http_myexample.com.error.log
</VirtualHost>
### <VirtualHost www.myexample.com:443>
<VirtualHost 192.168.1.122:443>
### <VirtualHost 111.111.111.111:443>
ServerAdmin admin#myexample.com
ServerName www.myexample.com
ServerAlias myexample.com
Alias /cloud /var/www/owncloud
DocumentRoot /var/www/owncloud/
####Configuration for SSL #####
SSLEngine on
SSLCertificateFile /etc/apache2/ssl/examplecloud.pem
SSLCertificateKeyFile /etc/apache2/ssl/examplecloud.key
#### End of SSL Configuration ####
<Directory /var/www/owncloud>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Require all granted
</Directory>
ErrorLog /var/log/apache_https_cloud.myexample.com.error.log
</VirtualHost>
~
Any help/insight would be much appreciated...
thanks,
Try Redirect permanent /cloud https://192.168.1.122/cloud
If that didn't work, try a more generic solution by replacing Redirect with:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI}