| Author | 
  | 
RevArie
 
 
  Joined: 07 Aug 2015 Posts: 5 Location: Rotterdam, Netherlands
  | 
 Posted: Fri 07 Aug '15 20:17    Post subject: Reverse proxy, rewrite | 
     | 
 
  | 
 
Apache 2.4.7 on Ubuntu 14.04 
 
 
I have 2 applications on this server:
 
1. Spotweb - https://github.com/spotweb/spotweb
 
2. Sabnzbd - http://wiki.sabnzbd.org/install-ubuntu-repo.
 
 
Goal: Access both applications on same server as:
 
1. nzb.example.org/spotweb -- Spotweb
 
2. nzb.example.org/ -- Sabnzbd
 
 
1. Spotweb config
 
 	  | Code: | 	 		             Alias /spotweb "/var/www/html/spotweb"
 
        <Directory /var/www/html/spotweb/>
 
                Options FollowSymLinks
 
                Require all granted
 
        </Directory>
 
 
 | 	  
 
 
2. Sabnzbd config
 
 	  | Code: | 	 		                  ServerName nzb.example.org
 
                ServerAlias nzb.example.org
 
                ProxyPreserveHost On
 
                ProxyRequests off
 
                ProxyPass /nzb http://nzb.example.org:8800/
 
                ProxyPassReverse /nzb http://nzb.example.org:8800/
 
 | 	  
 
Result for http://nzb.example.org/spotweb is a rewrite to: http://localhost:8800/sabnzbd
 
 
Result for http://nzb.example.org/ is good.
 
 
Confusing stuf.    | 
 
  | 
| Back to top | 
 | 
James Blond Moderator
  
  Joined: 19 Jan 2006 Posts: 7443 Location: EU, Germany, Next to Hamburg
  | 
 Posted: Mon 10 Aug '15 17:41    Post subject:  | 
     | 
 
  | 
 
| Is there a rewrite rule in the httpd.conf or in a .htaccess file in the root? | 
 
  | 
| Back to top | 
 | 
RevArie
 
 
  Joined: 07 Aug 2015 Posts: 5 Location: Rotterdam, Netherlands
  | 
 Posted: Mon 10 Aug '15 17:46    Post subject:  | 
     | 
 
  | 
 
| Yes, there is a .htaccess file in the root, but without rewrite rules, because I have commented them. | 
 
  | 
| Back to top | 
 | 
James Blond Moderator
  
  Joined: 19 Jan 2006 Posts: 7443 Location: EU, Germany, Next to Hamburg
  | 
 Posted: Mon 10 Aug '15 17:49    Post subject:  | 
     | 
 
  | 
 
I wonder...
 
 
you can try to disable the reverse proxy of the spotweb
 
 
 	  | Code: | 	 		  ProxyPass /spotweb !
 
ProxyPassReverse /spotweb ! | 	  
 
 
I'm not so sure if that helps. Trial and error. | 
 
  | 
| Back to top | 
 | 
RevArie
 
 
  Joined: 07 Aug 2015 Posts: 5 Location: Rotterdam, Netherlands
  | 
 Posted: Mon 10 Aug '15 18:43    Post subject:  | 
     | 
 
  | 
 
James! Thanks ever so much! This was spot on. The full config is now quite simple and effective.
 
 	  | Code: | 	 		  <VirtualHost *:80>
 
        ServerName nzb.example.org
 
        DocumentRoot /var/www/html/spotweb
 
 
        Alias /spotweb "/var/www/html/spotweb"
 
        <Directory /var/www/html/spotweb/>
 
                Options FollowSymLinks
 
                Require all granted
 
        </Directory>
 
 
        ProxyPreserveHost On
 
        ProxyRequests off
 
        ProxyPass /spotweb !
 
        ProxyPassReverse /spotweb !
 
        ProxyPass / http://nzb.example.org:8800/
 
        ProxyPassReverse / http://nzb.example.org:8800/
 
 
        LogLevel warn
 
        CustomLog ${APACHE_LOG_DIR}/access.log combined
 
</VirtualHost>
 
 | 	 
  | 
 
  | 
| Back to top | 
 | 
James Blond Moderator
  
  Joined: 19 Jan 2006 Posts: 7443 Location: EU, Germany, Next to Hamburg
  | 
 Posted: Mon 10 Aug '15 22:18    Post subject:  | 
     | 
 
  | 
 
Now I get the issue! 
 
 
You spotweb  folder as the document root and also as an alias. That is Why the .htaccess did mess. It would have been a lot easier if you just out the document root to /var/www/html even tho it is empty. Then you don't need the alias. | 
 
  | 
| Back to top | 
 | 
RevArie
 
 
  Joined: 07 Aug 2015 Posts: 5 Location: Rotterdam, Netherlands
  | 
 Posted: Tue 11 Aug '15 5:37    Post subject:  | 
     | 
 
  | 
 
OK, lesson learned. Next time I will post full config. Noticed the document root, and changed this as well. Thanks again.    | 
 
  | 
| Back to top | 
 |