0

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:

127.0.0.1    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/
</VirtualHost> 

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

testmask/

It redirects to:

http://testmask/MyWebapp/

So ok so far.

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

http://testmask/

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:

http://testmask/static/
|-  css/*
|-  js/*
|-  medias/*

while they are in:

http://testmask/MyWebapp/static/
|-  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.

0

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.

|improve this answer|||||

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.