Apache reverse proxy showing internal IP rather than domain in URL - apache

I have a simple reverse proxy running on a VM passing internet based requests to flask app on another VM.
All seems to work well but the URL is showing my internal IP address rather than my domain. This means the IP is exposed and any subsequest requests cannot be fulfiled.
I feel like a bit of an idiot here as I cannot work out the command to stop this happening.
My conf file looks like this:
<VirtualHost *:80>
ServerName xxx.xxxxxxxxxxx.co.uk
ServerAlias www.xxx.xxxxxxxxxxxxxx.co.uk
ServerAdmin webmaster#xxxxxxxxxxx.co.uk
ErrorLog "/var/log/apache2/xxxxxerror.log"
CustomLog "/var/log/apache2/xxxxxaccess.log" combined
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPreserveHost off
ProxyPass / http://192.168.1.21:5050/
ProxyPassReverse / http://192.168.1.21:5050/
</VirtualHost>
Can anyone help point out my stupid mistake?
I get this is the URL after I make initial contact: http://192.168.1.21:8051/
Thanks
I have tried everyhting I know but the stupid filter is strong today

Related

apache2 proxy redirect configuration

This has been asked a bunch of time I realize but I still can't seem to get it working. Here is my situation. I have 2 servers on my network. Server A is public facing which hosts my website. My second server also has apache running with a web application which I would like to access externally. I am not exactly sure how to configure this. My current config looks like this
NameVirtualHost *:2323
<VirtualHost *:2323>
ProxyPass / http://192.168.1.7/ampache
ProxyPassReverse / http://192.168.1.7/ampache
servername slave-1
ProxyPreserveHost On
ProxyRequests Off
</VirtualHost>
So I would like all traffic on https://my_domain.xx:2323 to redirect to 192.168.1.7/ampache
Thank you
I fixed it by doing the following
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
ProxyPass /airsonic http://192.168.1.7:8088/airsonic
ProxyPassReverse /airsonic http://192.168.1.7:8088/airsonic

Tableau Reverse Proxy Issue

I want to make Tableau (which is on an internal network) accessible on the public network. One of the ways recommended by Tableau Support is a Reverse Proxy.
I have set up the required modules and have the reverse proxy functioning. The login page is available through these settings in httpd given below. However, once I log in and want to open Projects, Views etc. It routes to
http://actualsite.com/#/vieworproject
which should actually be http://actualsite.com/tableauaccess/#/vieworproject.
Here is the httpd configuration:
ProxyPass /tableauaccess/ http://tableauserverexample.com/
ProxyPassReverse /tableauaccess/ http://tableauserverexample.com/
<Location /tableauaccess/>
Order deny,allow
Allow from all
ProxyHTMLURLMap / /tableauaccess/
</Location>
This doesnt solve the main issue with #. I tried
ProxyPass /#/ http://tableauserverexample.com/#/
ProxyPassReverse /#/ http://tableauserverexample.com/#
But it doesnt help. Any suggestions?? Thanks!
We had this same issue recently. Your httpd.conf file is technically correct for mod_proxy, however the url you are attempting to use is not supported by Tableau. You cannot use:
http://actualsite.com/tableauaccess
But rather you must use the format:
http://tableauaccess.actualsite.com
We ended up setting up that sub-domain name and then using a VirtualHost block such as:
Listen 80
NameVirtualHost *:80
<VirtualHost *:80>
ServerName actualsite.com
DocumentRoot "/path/path2/pathx"
</VirtualHost>
<VirtualHost *:80>
ServerName tableauaccess.actualsite.com
ProxyRequests Off
ProxyPreserveHost On
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://tableauaccess.actualsite.com/
ProxyPassReverse / http://tableauaccess.actualsite.com/
<IfModule mod_cache.c>
CacheDisable *
</IfModule>
RequestHeader set X-Forwarded-Proto "http" #or "https", depending on preference
</VirtualHost>
Be sure to double-check your Tableau server to update the URL format.
Sources:
https://community.tableau.com/thread/198095
https://community.tableau.com/thread/218678
(I don't have enough reputation points to post all of my sources, but thanks to Tableau community, shanemadden at ServerFault, and the Apache documentation.)
edit: forgot trailing slashes

changing base url displayed

here is my setup, I'm using 1 server to accept connections externally then redirects to one of my two websites, i am currently trying out reverse proxy, when i try to access www.example1.com i can successfully load the site, but when i go to my pages, my url displays x.x.x.1/page,what i want is www.example1.com/page I have been reading .htaccess notes also, but have not yet tried any of it, I need suggestions on how to solve this
Additional: my 2 websites are on different servers
if anyone experience a setup similar to mine, here is what i did
<VirtualHost *:80>
DocumentRoot "\x.x.x.x\var\www\example1"
ServerName www.example1.com
ServerAlias example1.com
<Proxy *>
AllowOverride All
Order deny,allow
Allow from all
</Proxy>
<Location / >
ProxyPreserveHost On
ProxyPass "http://x.x.x.x/"
ProxyPassReverse "http://x.x.x.x/"
</Location>
</VirtualHost>

Two servers with mod_proxy, second server host is local ip and shows /proxy/ in url?

I am having some issues in regards to sessions with a second server I am running on my home network. I do this as a hobby and to develop new applications before they officially go live.
I have a domain pointing to my ip and resolves successfully to server 1, but after configuring mod_proxy to send specific domains to server 2 I am getting some unwanted errors and results. I want the second server to act as a normal server and just go through the first server since my current router can only send port 80 to one local ip and not filter it.
I have a.mydomain.com for my second server and it resolves fine but When I try to use a web application on this second server I get the following error
Warning: You are now accessing Mydomain from http://10.0.1.38/, but Mydomain has been configured to run at this address: http://a.mydomain.com/
Can i fix this?
Also when trying to access phpmyadmin via the a.mydomain.com/phpmyadmin it will change to a.mydomain.com/proxy/phpmyadmin after logging in, can i change this so that it's basically seamless and does not add /proxy.
Here is my vhost config for server 1
<VirtualHost *:80>
DocumentRoot /var/www/html
ServerName www.server1domain.net
</VirtualHost>
<VirtualHost *:80>
ProxyPreserveHost On
ServerName a.mydomain.com
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass / http://10.0.1.38/
ProxyPassReverse / http://10.0.1.38/
</VirtualHost>
Here is the vhost config for server 2
<VirtualHost *:80>
ServerAdmin admin#mydomain.com
DocumentRoot /var/www/mydomaincom
ServerName a.mydomain.com
</VirtualHost>
I am running Centos 6.4
Alright I finally figured this out, some of the stuff is a little obvious now but this works for anyone else in a similar situation.
So earlier in my http.conf I had this
<IfModule mod_proxy.c>
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
# destination directory
ProxyPass /proxy http://10.0.1.38
ProxyPassReverse /proxy http://10.0.1.38
</IfModule>
There seems to be two problems with this, it seems to add the /proxy/ directory and also is wrong since the ip does not have a trailing slash, thus I changed it to this
<IfModule mod_proxy.c>
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
</IfModule>
And my http.conf vhost config for the first server looks like this now
<VirtualHost *:80>
ProxyPreserveHost On
ProxyPass / http://10.0.1.38/
ServerName a.mydomain.com
</VirtualHost>
If you forget the trailing slash after the ip you will most likely end up with 502 errors: Could not resolve dns
The second servers vhost config looks like this
<VirtualHost *:80>
ServerAdmin admin#mydomain.com
DocumentRoot /var/www/mydomain
ServerName a.mydomain.com
</VirtualHost>
Hope that helps anyone else with similar issues.

Apache ProxyPass for URLS inconsistently failing

This one's driving me nuts. I have an active and in-use Apache proxy server serving content up on EC2. It's working great, and has a variety of vhosts that are configured like this:
<VirtualHost *:80>
ServerName m.FOO.com
ServerAlias customer.FOO.com
ProxyPreserveHost On
ProxyPass / ajp://10.211.42.48:8009/
ProxyPassReverse / ajp://10.211.42.48:8009/
<Proxy ajp://10.211.42.48:8009/*>
Order allow,deny
Allow from all
</Proxy>
</VirtualHost>
These all work great, and I'm having no problems. Now what I'd like to do is move it so instead of a single vhost for each app, I want to have a sub-url on the main site that proxies back to the appserver. So instead of a customer having 'customer.FOO.com', they'll have 'FOO.com/customer/'
Great, sounds easy, right? Yeah, not so much. I edit the vhost entry for 'root' of the server (currently showing the landing page), and add the proxy entries to directories within that. That should do it,right? Yeah, it ain't:
<VirtualHost *:80>
ServerName web01.aws.FOO.com
DocumentRoot /var/www/html
ErrorLog logs/www.FOO.com-error_log
CustomLog logs/www.FOO.com-access_log common
<Location /a>
ProxyPass ajp://10.211.42.48:8009
ProxyPassReverse ajp://10.211.42.48:8009
</Location>
<Location /t>
ProxyPass http://adm01
ProxyPassReverse http://adm01
</Location>
<Proxy ajp://10.211.42.48:8009/*>
Order allow,deny
Allow from all
</Proxy>
</VirtualHost>
If i hit http://www.FOO.com/t/ - I get the internal webserver - it proxies forward correctly, and all is well. If I hit http://www.FOO.com/a/ I get a 404 error. The access log even shows a 404 error.
Note that the ProxyPass AJP entries are identical to what's in the other vhost entry. So why does it work on the root on the other vhost entry, and not as a subdir here on the main vhost?
Halp!
I ended up solving this with one particular hint I found out on a mailing list somewhere. The ProxyPassReverse directive is very touchy, and has one basic function. Anything it matches on the second argument (assuming using the ProxyPassReverse A B form) will be applied to the first argument. So it's critical to make sure the second argument is exactly the redirect that is coming from your application, or else the ProxyPassReverse directive will be ignored.
In my case, what I ended up doing was changing the Location entry to:
ProxyPass /a/ ajp://10.211.42.48:8009
ProxyPassReverse /a/ http://my.apphost.com/
And all started working just fine.