Access CouchDB Fauxton UI from subdomain - apache

Remote Server: Ubuntu 14.04 Headless
I've setup Couchdb v2.0.0 successfully, and can access it remotely via www.[mydomain].com:5984/_utils
I want to create a subdomain to access this URL, something like dbadmin.[mydomain].com
First, I created a subdomain of db.[mydomain].com (Here's the apache2 vhost config:)
<VirtualHost *:80>
ServerName db.[mydomain].com
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Off
<Proxy *>
Require all granted
</Proxy>
ProxyPass / http://db.[mydomain].com:5984/
ProxyPassReverse / http://db.[mydomain].com:5984/
</VirtualHost>
Note: I have replaced [mydomain] with the actual domain ;P
I then created an A Record with my DNS Registrar as follows:
db A [PublicIP]
and then a SRV Record:
_db._tcp.db SRV 0 5 5984 db.[mydomain].com
and I test it by going to http://db.[mydomain].com/ on my laptop
Result: {"couchdb":"Welcome","version":"2.0.0","vendor":{"name":"The Apache Software Foundation"}}
So a success, I think. Now, I create the dbadmin subdomain. Apache2 vhost config:
<VirtualHost *:80>
ServerName dbadmin.[mydomain].com
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Off
<Proxy *>
Require all granted
</Proxy>
ProxyPass / http://db.[mydomain].com:5984/_utils
ProxyPassReverse / http://db.[mydomain].com:5984/_utils
</VirtualHost>
Then another A Record:
dbadmin A [PublicIP]
Followed by another SRV Record:
_dbadmin._tcp.dbadmin SRV 0 5 5984 dbadmin.[mydomain].com
I test it by visiting http://dbadmin.[mydomain].com
Result: {"error":"unauthorized","reason":"You are not a server admin."}
I have spent far too many hours trying to suss out the proper way of doing this. I've tried all sorts of configurations, settings, DNS Records, changing couch's local.ini, proxy settings... You get the idea.
Please, elucidate how I can simply redirect a subdomain to either the server's public IP + port + path or the server's root domain + port + path?

I solved this with mod_rewrite in the VHost config:
<VirtualHost *:80>
ServerName dbadmin.[mydomain].com
ProxyRequests Off
ProxyPreserveHost On
ProxyVia Off
<Proxy *>
Require all granted
</Proxy>
ProxyPass / http://db.[mydomain].com:5984/
ProxyPassReverse / http://db.[mydomain].com:5984/
RewriteEngine on
RewriteCond %{REQUEST_URI} !^/_utils
RewriteRule ^/$ /_utils/$1 [R,L]
It appears that I didn't even need the SRV Record, either. Groovy!
Can anyone succinctly explain to me what the Regex for this condition and rule are actually doing? I know at a basic level that it looks for /_utils in the query, and if not there, it puts it there...
The rule does however remove the protocol identifier 'http://' from the beginning of the URL, which is rather annoying... Can anyone explain why, and how to prevent that from happening?

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

Apache listen and redirect to a different port

I know this has been asked before, I used the highest rated question as a baseline, but I still can't get it to work.
I'm trying to host a website through an iocage jail in FreeBSD.
In my jail I'm hosting a domain called sub.domain.com. I've managed to get Apache to listen to a different port, 10080. So when I go to sub.domain.com:10080 I can access my website.
I would like to be able to go sub.domain.com and also access my website. As far as I understand, I need to redirect using mod_proxy to allow 80 -> 10080.
In httpd.conf I uncommented mod_proxy and added the following
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName www.sub.domain.com
ServerAlias sub.domain.com
ProxyPass / http://localhost:10080
ProxyPassReverse / http://localhost:10080
</VirtualHost>
This doesn't work for me, I still have to go to sub.domain.com:10080 to access my website.
Any tips?
EDIT: current config, also doesn't work
<VirtualHost *:80>
ProxyPreserveHost On
ProxyRequests Off
ServerName <jailip>
ServerAlias <jailip>
ProxyPass / http://<jailip>:10080
ProxyPassReverse / http://<jailip>:10080
</VirtualHost>

Apache forward proxy by url parameter

I want redirect any access whose URL parameter is "deep" to local server, and redirect other access to other server.
Forward a request like the following:
① url parameter starting with deep
http*://hostname/bdd?deep=1
→
http*://127.0.0.1:8080/bdd
② other url
→
http*://10.137.213.101:8080/bdd
I am setting my apache conf as the following, but it still does not work.
RewriteEngine On
RewriteCond %{QUERY_STRING} ^deep
RewriteRule "^/bdd(.*)$" /dataviewlinks/ [L]
ProxyPass /dataviewlinks http*://127.0.0.1:8080/bdd
ProxyPassReverse /dataviewlinks http*://127.0.0.1:8080/bdd
ProxyPass /bdd http*://10.137.213.101:8080/bdd
ProxyPassReverse /bdd http*://10.137.213.101:8080/bdd
What could be the solution?
I have done it like this in the past to redirect any network access on port 8080 to another directory.
<VirtualHost *:8080>
ServerName 127.0.0.1
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyRequests On
ProxyPreserveHost On
ProxyPass "/" "http://10.137.213.101:8080/bdd"
ProxyPassReverse "/" "http://10.137.213.101:8080/bdd"
</VirtualHost>
Maybe this would work for you as well.
Also make sure you have enabled proxy mod sudo a2enmod proxy and restart apache

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

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.