I got Apache Web Server 2.4, and a JBoss 7 exposing a web project.

Since I'm working locally I made an /etc/hosts/ domain entry like:    testmask

And put this virtual host config inside my Apache:

<VirtualHost *:80>   
    ServerName testmask/
    ServerAlias  testmask
    RewriteEngine  on 
    RewriteRule   ^/$  http://testmask/MyWebapp/  [R] 
    ProxyPass / http://testmask:8080/
    ProxyPassReverse / http://testmask:8080/

And this works like a charm. If I put on browser:


It redirects to:


So ok so far.

Now since I would like to have the same result but leaving only:


I've made a proxy on rewrite rule:

RewriteRule   ^/$  http://testmask/MyWebapp/  [P] 

But I got a 404 not found problem on css and js that are relative to context root.

This is because my browser is trying to get css and js from:

|-  css/*
|-  js/*
|-  medias/*

while they are in:

|-  css/*
|-  js/*
|-  medias/*

(typical folder structure of build\ReactJS create-react-app).

Tried different approaches via RewriteRules or Proxypass but nothing works, probably due to my poor experience on Apache.

Consider I prefer not to touch the index.html since my projects need to live alone also, since I'm developing it via npm.


I would try with mod_proxy.

First enable:

a2enmod mod_proxy
a2enmod mod_proxy_http

Then in your apache config it would look like this:

ProxyPass / http://localhost/MyWebapp
ProxyPassReverse / http://localhost/MyWebapp

So now if you connect to http://localhost/ (or in your case http://testmask/) it should be proxy to MyWebapp.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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