Description:
I have an Appsmith instance running on a virtual machine (VM). The instance hosts two applications within the same workspace. I have an Nginx server running on the VM, which currently allows access to the Appsmith instance from a specific subdomain (subdomain 1).
Goal:
I want to achieve the following:
Access the Appsmith instance through two additional subdomains, where each subdomain serves a specific Appsmith application.
Each subdomain should mirror the deployment URL of the applications without changing their original URLs.
Ensure all redirections use HTTPS.
Requirements:
Subdomain 1: Hosts the Appsmith instance (e.g., https://subdomain1.com/applications)
Subdomain 2: Should mirror the first Appsmith application URL (e.g., https://subdomain1.com/app/appName/log-in-123c12d2e123a86fcasbeabc?branch=master) but use https://subdomain2.com/app/appName/log-in-123c12d2e123a86fcasbeabc?branch=master as the URL.
Subdomain 3: Should mirror the second Appsmith application URL as subdomain 2 but use https://subdomain3.com/app/appName/log-in-123c12d2e123a86fcasbeabc?branch=master as the URL.
All redirections should force HTTPS.
What I’ve Tried:
I have set up Nginx to serve the Appsmith instance on subdomain 1, but I’m unsure how to configure it to mirror the application URLs on subdomain 2 and subdomain 3 without changing the URLs. Now it redirects to those subdomains but it does not conserves the urls that i need, it shows the subdomain 1.
Question:
How can I configure Nginx to achieve this mirroring setup? What are the specific configurations or rules I need to apply in the Nginx configuration file?
Additional Information:
Nginx version: nginx/1.22.1
Appsmith version: Appsmith Community v1.28
VM Operating system: Debian GNU/Linux 12 (bookworm)
server {
listen 80;
server_name subdomain1.com;
location / {
proxy_pass http://localhost:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
if ($scheme != "https") {
return 301 https://$host$request_uri;
}
}
server {
listen 80;
server_name subdomain2.com;
location / {
proxy_pass http://subdomain1.com;
proxy_set_header Host subdomain2.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
if ($scheme != "https") {
return 301 https://$host$request_uri;
}
}
server {
listen 80;
server_name subdomain3.com;
location / {
proxy_pass http://subdomain1.com;
proxy_set_header Host subdomain3.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
# Force HTTPS
if ($scheme != "https") {
return 301 https://$host$request_uri;
}
}