-
-
Notifications
You must be signed in to change notification settings - Fork 80
03. Reverse Proxy Setup
Mygod edited this page Sep 27, 2025
·
5 revisions
This is a basic setup to get ReactMap running with Nginx. It is highly recommended to enable SSL (HTTPS) for production systems for both security and the "locate me" feature. That topic is beyond the scope of this documentation and there are many ways to implement it.
- How To Secure Nginx with Let's Encrypt on Ubuntu 20.04
- How To Host a Website Using Cloudflare and Nginx on Ubuntu 20.04
sudo apt-get updatesudo apt-get install nginxsudo nano /etc/nginx/conf.d/default.conf- Copy and paste the following into the file:
server {
listen 80;
listen [::]:80;
server_name your_map_url.com;
location / {
proxy_pass http://127.0.0.1:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_request_buffering off;
proxy_buffering off;
proxy_set_header Connection keep-alive;
}
}- Uncomment the nginx section in the
docker-compose.example.ymlfile. - Create your config file:
touch server/src/configs/nginx.conf - Copy and paste the following into the file:
server {
listen 80;
listen [::]:80;
server_name your_map_url.com;
location / {
proxy_pass http://reactmap:8080/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_request_buffering off;
proxy_buffering off;
proxy_set_header Connection keep-alive;
}
}- How To Use Apache HTTP Server as Reverse-Proxy Using mod_proxy Extension (Ubuntu 20.04)
- How To Secure Apache with Let's Encrypt on Ubuntu 20.04
Credit to: M3G4THEKING
sudo apt-get updatesudo apt install apache2sudo ufw app listsudo ufw allow 'Apache'sudo ufw statussudo systemctl status apache2- Visit
http://your_server_ipto confirm Apache is running. sudo mkdir /var/www/your_domainsudo chown -R $USER:$USER /var/www/your_domainsudo chmod -R 755 /var/www/your_domain- Create a virtual host file at
/etc/apache2/sites-available/your_domain.conf(for example withsudo nano /etc/apache2/sites-available/your_domain.conf). - Insert the following configuration:
<VirtualHost *:80>
ServerAdmin webmaster@localhost
ServerName your_domain
ServerAlias www.your_domain
DocumentRoot /var/www/your_domain
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>sudo a2ensite your_domain.confsudo a2dissite 000-default.confsudo apache2ctl configtestsudo systemctl restart apache2- Apache should now serve your domain at
http://your_domain.
sudo a2enmod proxy proxy_http proxy_balancer lbmethod_byrequestssudo systemctl restart apache2- Edit
/etc/apache2/sites-available/your_domain.confand add a reverse-proxy block similar to the following:
<VirtualHost *:8080>
ServerAdmin webmaster@your_domain
ServerAlias your_domain
DocumentRoot /var/www/your_domain/
ProxyPreserveHost On
ProxyPass / http://your_ip:8080/
ProxyPassReverse / http://your_ip:8080/
RewriteCond %{HTTP_HOST} !^reactmap\.your_domain\.net$ [NC]
RewriteRule ^/$ http://%{HTTP_HOST}/ [L,R=301]
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>sudo systemctl restart apache2- Apache is now configured as a reverse proxy for ReactMap.
sudo apt install certbot python3-certbot-apachesudo apache2ctl configtestsudo systemctl reload apache2
sudo ufw statussudo ufw allow 'Apache Full'sudo ufw delete allow 'Apache'
sudo certbot --apache- Provide a valid email address when prompted and press
ENTER. - Read the Let's Encrypt terms of service, then press
Afollowed byENTERto agree. - Choose whether to share your email with the Electronic Frontier Foundation (
YorN). - Select the domains you want to secure (for example,
1foryour_domain,2forwww.your_domain, or leave the prompt blank to select all listed domains). - When asked about redirecting HTTP traffic to HTTPS, choose option
2to force HTTPS (recommended) or option1to keep both available. - After the prompts, Certbot installs your certificate and displays the certificate and key file paths.
A good way to validate the certificate is with these links:
https://www.ssllabs.com/ssltest/analyze.html?d=your_domainhttps://www.ssllabs.com/ssltest/analyze.html?d=www.your_domain
Let's Encrypt certificates are only valid for ninety days. The Certbot package installs a renewal script in /etc/cron.d, managed by the certbot.timer systemd service. The script runs twice a day and automatically renews certificates that are within thirty days of expiration.
To confirm the renewal service is active and functioning, run:
sudo systemctl status certbot.timersudo certbot renew --dry-run