Publish a ReactJs app behind HaProxy (in a subpath)

How to configure a React app to be served from a subpath in HaProxy
haproxy reactjs tech

Publish a ReactJs app behind HaProxy (in a subpath)

I started with the intent of deploying directly a ReactJS app embedded in a tomcat container behind HaProxy. As it turns out, it is terribly difficult (even possible at all ?) to have it behind a HaProxy and in a subpath.

Apache backend server

RewriteEngine On
RewriteRule ^ - [L]

# Fallback all other routes to index.html
RewriteRule ^ /react/index.html [L]

That means: whenever I type something in the browser bar that resembles something different from the index.html page, I get redirected to the same index.html. I can actually put those directives in the .htaccess in the root of my application. To make sure this .htaccess file get read, my apache domain config will look somewhat like this:

Listen 10091
<VirtualHost *:10091>
    DocumentRoot /var/www/

<Directory "/var/www/">
    AllowOverride All

My ReactJs application will be deployed in the directory: /var/www/ , that goes without saying.

ReactJs configuration

In my React application, I need to be aware of the fact that I am going to deploy to a subdir, in two places:

  <BrowserRouter basename='/react/'>
        <div className="App">
          <MainRouter />
  "homepage": "",

HaProxy front-end

If I were to open the 10091 port to the world, I would be done, but that’s not what I want, because I want to use HaProxy for TLS termination. That’s my haproxy config for it:

backend be_apache_kevwe
        server static check

frontend fe_blackcheck
    acl url_black path_beg /blackcheck
    bind <my-ip-address>:443 ssl crt /etc/haproxy/
    default_backend be_apache_kevwe

How to delete all local Docker instances

Have you filled your disk because of Docker instances ?
docker linux tech

How to delete all local Docker images

Have you ever filled your disk because of Docker images ?
docker linux tech

Java text blocks as preview in Jdk 13

Java 13
java jdk jdk13 tech