So my goal is I have my domain named example.com
conf for example.com
<VirtualHost *:80>
ServerName example.com
ServerAlias www.example.com
ServerAdmin webmaster@localhost
DocumentRoot /var/www/public_frontend
<Directory "/var/www/public_frontend">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
RewriteEngine on
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
RewriteEngine On
RewriteCond %{SERVER_PORT} !443
RewriteRule ^(/(.*))?$ https://%{HTTP_HOST}$1 [R=301,L]
</VirtualHost>
^ this conf is for my react app which contains an .htaccess file:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule ^.*$ / [L,QSA]
</IfModule>
And I have my laravel backend layer which is reffered to in my app as localhost:8000
here is it's conf file
Listen 8000
<VirtualHost *:8000>
ServerName example.com
ServerAlias localhost
ServerAdmin webmaster@localhost
DocumentRoot /var/www/api/public
<Directory "/var/www/api/public">
Options FollowSymLinks Indexes MultiViews
AllowOverride All
Order allow,deny
Require all granted
RewriteEngine On
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
.htaccess of the laravel api
<IfModule mod_rewrite.c>
<IfModule mod_negotiation.c>
Options -MultiViews -Indexes
</IfModule>
RewriteEngine On
# Handle Authorization Header
RewriteCond %{HTTP:Authorization} .
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
# Redirect Trailing Slashes If Not A Folder...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_URI} (.+)/$
RewriteRule ^ %1 [L,R=301]
# Send Requests To Front Controller...
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-f
RewriteRule ^ index.php [L]
RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
</IfModule>
Mysql is correctly installed, Laravel is correctly installed
My problem is the following: My react app is timing out on the requests.
Error: timeout of 5000ms exceeded
createError createError.js:16
handleTimeout xhr.js:96
EDIT: If I start my development server locally and try my APACHE server it does request to localhost on my LOCAL machine.
How to bind apache2 request to localhost to the actual localhost?
netstat output
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:xxxx 0.0.0.0:* LISTEN
tcp6 0 0 :::443 :::* LISTEN
tcp6 0 0 :::8000 :::* LISTEN
tcp6 0 0 :::33060 :::* LISTEN
tcp6 0 0 :::3306 :::* LISTEN
tcp6 0 0 :::80 :::* LISTEN
PS: I will leave the question Open, but I've ended up using nginx. Someone pointed out that my case should be possible with mod_proxy.