2

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

VC1
  • 1,660
  • 4
  • 25
  • 42
Uberswe
  • 1,038
  • 2
  • 16
  • 36

1 Answers1

0

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.

Uberswe
  • 1,038
  • 2
  • 16
  • 36
  • 1
    I spent almost a day trying to put this scenario to work. Tried many configurations in the original **000-default.conf** file. All seemed correct, but didn't work. I had enabled **proxy** module on Apache2, but didn't enable the **proxy_http** apache2 module. So, when I **a2enmod proxy_http** the scenario started to work. Hope this can help anyone. – alexscmar Dec 13 '15 at 19:25