Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I tried to configure apache2 reverse proxy:

<VirtualHost *:80>
    ServerAdmin webmaster@localhost

    <Proxy *>
        Order deny,allow
        Allow from all
    </Proxy>

    ProxyPass           /stag http://127.0.0.1:9001
    ProxyPassReverse    /stag http://127.0.0.1:9001

    DocumentRoot /var/www
    <Directory />
        Options FollowSymLinks
        AllowOverride None
    </Directory>
    <Directory /var/www/>
        Options Indexes FollowSymLinks MultiViews
        AllowOverride None
        Order allow,deny
        allow from all
    </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    <Directory "/usr/lib/cgi-bin">
        AllowOverride None
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        Order allow,deny
        Allow from all
    </Directory>

    ErrorLog /var/log/apache2/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

</VirtualHost>

My Play instance run at localhost:9001, when I tried to call http://192.168.1.10:9001 it success, and cannot load all the files (image, css, js) inside the public folder of play project when try to call http://192.168.1.10/stag. When I check the url (using F12 on google Chrome) it comes to http://192.168.1.10/public/images/logo.png it supposed to http://192.168.1.10/stag/public/images/logo.png.

My question, is there a problem with my configuration of apache2 reverse proxy?

share|improve this question
add comment

1 Answer 1

Apache config is good, the a problem is in the contents of your HTML.

If your HTML points to the root..

<img src="/public/images/logo.png">

Then it points to the root, and the /stag prefix that your proxy is effectively adding is ignored. Your ProxyPass and ProxyPassReverse don't translate this for you.

On the other hand, if you allow the path to be relative..

<img src="public/images/logo.png">

Then, the relative path is kept and the resource can load.

There's also tools like mod_proxy_html that attempt to translate the paths in your HTML files, but they aren't foolproof; the better option is to make the contents work within the proxy.

share|improve this answer
    
No different if change to public/images/logo.png. I'll try to store at Tomcat and reverse proxy the tomcat. –  Crazenezz Jul 18 '12 at 4:19
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.