I have setup my lightsail instance with a static IP and my React app in the htdocs folder. I am trying to prevent anyone from accessing it via the public url. (Making it so that before you can access it, you need to be SSH'd into the lightsail instance.) Currently, my htaccess file currently only redirects the homepage and not any of the other pages. My htaccess file is as follows.
RewriteEngine On
RewriteBase /
RewriteCond %{HTTP_HOST} ^1.2.3.4$
RewriteRule ^/?$ http://127.0.0.1:8080 [R=301,L]
RewriteCond %{HTTP_HOST} ^1.2.3.4/About$
RewriteRule ^/?$ http://127.0.0.1:8080/About [R=301,L]
EDIT 1: As suggested below:
I have added the suggested code to my virtual host in 000-default.conf
. I have also installed what was needed and made sure everything was activated. I am able to restart Apache without any arrors. However, when I navigate to the public IP Address, it does not redirect to localhost. My code is as follows:
<VirtualHost *:*>
ProxyPreserveHost On
ProxyPass / http://127.0.0.1:8080/
ProxyPassReverse / http://127.0.0.1:8080/
ServerName localhost
</VirtualHost>