Frage

I have a CentOS box running a number of web applications and I use Apache to proxy requests to the various applications. All of them are working except an Erlang Nitrogen application which I can't seem to get working.

I am running the Nitrogen app in the standard way and it can be accessed locally on the machine at http://localhost:8000. I have verified this using wget.

Here is the apache configuration file I am trying to use:

ProxyRequests Off
ProxyPreserveHost On

<Proxy http://my-ip:8000/*>
  Order deny,allow
  Allow from all
</Proxy>

ProxyPass /erlang http://my-ip:8000/
ProxyPassReverse /erlang http://my-ip:8000/
ProxyPassReverse  /erlang  http://my-ip/

This setup is similar to all the other successfully working proxies on the system except that the other applications are not deployed to the root of their server like Nitrogen seems to be doing.

The result is that the basic page is downloading correctly into the web browser but all of the accompanying resources are not. This gives me an un-styled page where the javascript does not function correctly.

Here is the log from Apache:

x.x.x.x - - [timestamp] "GET /erlang HTTP/1.1" 200 2884
x.x.x.x - - [timestamp] "GET /nitrogen/jquery.js HTTP/1.1" 404 484
x.x.x.x - - [timestamp] "GET /nitrogen/jquery-ui.js HTTP/1.1" 404 484
x.x.x.x - - [timestamp] "GET /nitrogen/livevalidation.js HTTP/1.1" 404 484
x.x.x.x - - [timestamp] "GET /nitrogen/nitrogen.js HTTP/1.1" 404 484
x.x.x.x - - [timestamp] "GET /nitrogen/bert.js HTTP/1.1" 404 484
x.x.x.x - - [timestamp] "GET /nitrogen/jquery-ui/jquery.ui.all.css HTTP/1.1" 404 484
x.x.x.x - - [timestamp] "GET /nitrogen/nitrogen.css HTTP/1.1" 404 484
x.x.x.x - - [timestamp] "GET /css/style.css HTTP/1.1" 404 484

I have a hard requirement to use Apache as my proxy - I am not going to reset up all the other applications just to get this Nitrogen application working. Opening port 8000 in the firewall is also out of the question.

I am open to using any Apache module (mod-rewrite, etc) or any Apache setting as long as it doesn't affect the rest of the applications. I can also change any settings in the Nitrogen application to get it to play nicer with Apache.

How can I use Apache to proxy/reverse proxy for my Nitrogen application?

War es hilfreich?

Lösung 3

The issue is that ProxyPass only captures links coming in as requests to Apache. What was going wrong were links in the html page were pointing to resources that could not be requested and ProxyPass wasn't able to intercept them and route them correctly. This issue is documented here. See especially the section called "Fixing HTML Links".

I ended up having to install mod_proxy_html into Apache (no RPM for CentOS so I had to use apxs like the above document explained). After that I had to add some ProxyHTMLLinks for the resources that were giving me trouble and a ProxyHTMLURLMap directive to explain my mapping.

Here is my new configuration file:

ProxyRequests Off
ProxyPreserveHost On

<Proxy http://my-ip:8000/*>
  Order deny,allow
  Allow from all
</Proxy>

ProxyPass /erlang http://my-ip:8000/
ProxyHTMLURLMap http://my-ip:8000 /erlang

ProxyHTMLLinks  link            href
ProxyHTMLLinks  script          src for

<Location /erlang>
  ProxyPassReverse http://my-ip:8000/
  SetOutputFilter proxy-html
  ProxyHTMLExtended On
  ProxyHTMLURLMap / /erlang/
  RequestHeader unset Accept-Encoding
</Location>

What this literally does is intercept the html file and insert /erlang/ in front of all the urls. I can see the result of this when I use the show page source feature in my browser.

Andere Tipps

Problem: I set up Yaws wiki. It was working like http ://wiki:8080. But I wanted to work in this way (using apache): http ://wiki.local/

Solution:

Here my apache settings (/etc/apache/sites-available/wiki) for Yaws Wiki:

<VirtualHost *:80>
  ServerName wiki.local
  ProxyRequests Off
  <Proxy *>
    Order deny,allow
    Allow from all
  </Proxy>
  ProxyPass / http://wiki:8080/
  ProxyPassReverse / http://wiki:8080/
</VirtualHost>

My Yaws wiki setting (/etc/yaws/conf.avail/yaws-wiki.conf):

ebin_dir = /usr/lib/yaws/wiki/ebin
<server wiki>
 port = 8080
 listen = 0.0.0.0
 docroot = /var/lib/yaws-wiki
</server>

My /etc/hosts:

127.0.0.1 wiki
127.0.0.1 wiki.local

I have enabled these mods for apache:

sudo a2enmod proxy
sudo a2enmod proxy_http

Now http ://wiki.local/ works perfecly.

Are you sure that your Apache server is allowed to access those files? It looks like you're getting a HTTP 200 on the first address and a 404 on the rest. Make sure you're pointed to the correct location. :)

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top