Mobile app version of vmapp.org
Login or Join
Berumen354

: CGI with Reverse Proxy Settings (Apache) I have two VMs running two webapps. We want to use example.com/foo for accessing VM1, and example.com/bar for accessing VM2. For both VMs I need to call

@Berumen354

Posted in: #Apache2 #ReverseProxy

I have two VMs running two webapps. We want to use example.com/foo for accessing VM1, and example.com/bar for accessing VM2.

For both VMs I need to call a cgi script for downloading. So I have ScriptAlias "/cgi-bin/" "/opt/example/lib/", and use example.com/cgi-bin/download.pl to download files.

When the VMs have its own domain, it works fine. But now we want to have the example.com/foo and example.com/bar setup, the download function on VM2 stopped working. As both VMs will call the script on VM1, and VM1 will return an error.

How shall I setup the Apache, so I can use example.com/foo/cgi-bin/download.pl to download the files on VM1 and use example.com/bar/cgi-bin/download.pl to download the files on VM2?

I have tried to set ScriptAlias "/foo/cgi-bin/" "/opt/example/lib/" but it didn't work.

Apache conf on VM1,

<VirtualHost *:80>
ServerName example.com
ScriptAlias "/cgi-bin/" "/opt/example/lib/"
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPreserveHost On
ProxyPass /bar x.x.x.x/bar ProxyPassReverse /bar x.x.x.x/bar </VirtualHost>

Alias /foo /opt/example/script/fastcgi.pl/

<Directory "/opt/example/lib/">
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
AddHandler cgi-script .pl
SetHandler cgi-script
</Directory>

FastCgiServer /opt/example/script/fastcgi.pl -processes 3 -idle-timeout 3600

<Directory "/opt/example/script/">
Require all granted
</Directory>


Apache conf on VM2,

<VirtualHost *:80>
ServerName example2.com
ScriptAlias "/cgi-bin/" "/opt/example/lib/"
</VirtualHost>

Alias /bar /opt/example/script/fastcgi.pl/

<Directory "/opt/example/lib/">
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Require all granted
AddHandler cgi-script .pl
SetHandler cgi-script
</Directory>

FastCgiServer /opt/example/script/fastcgi.pl -processes 3 -idle-timeout 3600

<Directory "/opt/example/script/">
Require all granted
</Directory>

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Berumen354

1 Comments

Sorted by latest first Latest Oldest Best

 

@Heady270

In your scenario you actually need three webservers:


webapp "foo"
webapp "bar"
a front end webserver


The front end webserver virtual host will look like:

<VirtualHost *:80>
ServerName example.com
ProxyRequests Off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPreserveHost On
ProxyPass /bar x.x.x.x/ ProxyPassReverse /bar x.x.x.x/ ProxyPass /foo x.x.x.x/ ProxyPassReverse /foo x.x.x.x/ </VirtualHost>


Then set up your VM virtual hosts as you had done when they worked.

The "front end" webserver could be a separate virtual host running on one of the two existing VMs if you don't want to create another VM specifically for it.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme