Virtual host with XAMP and APPSERVER - apache

I have XAMPP and Appserver installed in one server (The first listens port 8080 and the second listens port 80).
I have a domain: example.com
I have this in APPSERV:
<VirtualHost 1.2.3.4:80>
ServerName example.com
DirectoryIndex index.php index.html
DocumentRoot "C:/appserv/www/folder"
</VirtualHost>
Is there a way so I can send that request to port 8080?

Here is a simplified version of how I accomplished it with ProxyPreserveHost
<VirtualHost www.example.com:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName www.example.com
ServerAlias example.com
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
</VirtualHost>

Related

Apache reverse proxy match requests

My server hosts two web services: WordPress(on Port 8080) and Flask(on Port 8081). I am setting up a reverse proxy as I want any requests start with /admin goes to Flask and all others go to Wordpress.
For example:
http://aa.mcmaster.ca/admin/aa Goes to Port 8080
http://aa.mcmaster.ca/page1 Goes to Port 8081
http://aa.mcmaster.ca/page1 Goes to Port 8081
My setting is:
<VirtualHost *:80>
DocumentRoot /wordpress/wp-content
SSLProxyEngine On
ProxyPreserveHost On
ServerName aa.mcmaster.ca
ProxyRequests off
ProxyPass /admin http://aa.mcmaster.ca:8080/
ProxyPassReverse /admin http://aa.mcmaster.ca:8080/
</VirtualHost>
<VirtualHost *:80>
DocumentRoot /wordpress/wp-content
SSLProxyEngine On
ProxyPreserveHost On
ServerName aa.mcmaster.ca
ProxyRequests off
ProxyPass /http://aa.mcmaster.ca:8081/
ProxyPassReverse / http://aa.mcmaster.ca:8081/
</VirtualHost>
It doesn't work. I am stuck on how to set up to matchs requests other than /admin. Can I get some help?
Thanks!
Use below ProxyPass in a single VirtualHost and test.
ProxyPass /admin/ http://aa.mcmaster.ca:8080/
ProxyPassReverse /admin/ http://aa.mcmaster.ca:8080/
ProxyPass / http://aa.mcmaster.ca:8081/
ProxyPassReverse / http://aa.mcmaster.ca:8081/

Domain redirected you too many times

I have an Apache web server.
I would like to setup a reverse proxy to access a local application running on port 9090.
Here is my apache configuration :
ProxyRequests Off
NameVirtualHost *:80
NameVirtualHost *:443
SSLProtocol ALL -SSLv2 -SSLv3
SSLHonorCipherOrder On
SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA
# Redirect HTTP requests to HTTPS
<VirtualHost *:80>
DocumentRoot "${SRVROOT}/htdocs/example.com/public_html"
ServerName example.com
ServerAlias example
Redirect / https://www.example.com/
</VirtualHost>
<VirtualHost *:443>
DocumentRoot "${SRVROOT}/htdocs/example.com/public_html"
ServerName example.com
ServerAlias example
ProxyPass / http://127.0.0.1:9090/
ProxyPassReverse / http://127.0.0.1:9090/
ProxyPreserveHost On
RequestHeader unset Origin
</VirtualHost>
The configuration is not working. I'm getting the error : example.com redirected you too many times
The server is hosted at an EC2 AWS instance.
Does anyone know how to solve that please ?
Thanks.

apache redirect port from 8000 to 80

I am trying to redirect the URL from http://10.11.12.221:8000/ to http://10.11.12.221/index.html from port 8000 to 80. I did the following in ports.conf file but didn't work.
Listen 80
Listen 8000
<VirtualHost *:8000>
redirect / http://10.11.12.221/index.html
</VirtualHost>
I also try the following but doesn't work too.
<VirtualHost *:8000>
ProxyPreserveHost On
ProxyRequests Off
ServerName 10.11.12.221
ServerAlias 10.11.12.221
ProxyPass / http://10.11.12.221:80/index.html
ProxyPassReverse / http://10.11.12.221:80/index.html
</VirtualHost>
any ideas why? Thanks so much!!!

Use Proxy to redirect my Site?

I want to redirect my Apache Server to my node server running on other
port on localhost Like when i enter localhost:80 it should redirect my node server which is running on localhost:3000.
<VirtualHost *:3000>
ProxyPreserveHost On
ProxyRequests Off
ServerName www.example.com
ServerAlias example.com
ProxyPass / http://localhost:80/example/
ProxyPassReverse / http://localhost:80/example/
</VirtualHost>

Redirect a virtualhost http & https to another virtualhost server

I have 2 apache 2.4 serverA and serverB with several virtualhost. All incoming requests arrive on serverA.
How do I forward http and https request for a specific virtualhost name from serverA to serverB?
My wamp ServerA setup is:
into my hosts file
127.0.0.7 example.com
The virtualhost:
<VirtualHost *:*>
ServerName example.com
ProxyPreserveHost On
ProxyPass "/" "http://192.168.1.105/"
ProxyPassReverse "/" "http://192.168.1.105/"
</VirtualHost>
My serverB ip is 192.168.1.105 and I setup a virtual host on it with the same name example.com
when I use http://example.com I stay on the wamp home page like http://localhost
and when I use https://example.com I have error 403 (Forbidden) on serverA
After a long night, I find a solution:
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass "/" "http://192.168.1.105/"
ProxyPassReverse "/" "http://192.168.1.105/"
ServerName example.com
</VirtualHost>
<VirtualHost *:443>
SSLProxyEngine on
SSLCertificateFile "${APACHE_DIR}/conf/ssl_example.com/server.crt"
SSLCertificateKeyFile "${APACHE_DIR}/conf/ssl_example.com/server.key"
ErrorLog "logs/example.com-ssl_error.log"
CustomLog "logs/example.com-ssl_access.log" common
ProxyPreserveHost On
ProxyPass "/" "https://192.168.1.105/"
ProxyPassReverse "/" "https://192.168.1.105/"
ServerName example.com
</VirtualHost>
in ServerA virtualhost add a simple:
Redirect / https://serverb.examample.com/