Skip to content

[Feature request]: Support for subpath hosting #835

@rohankanhaisingh

Description

@rohankanhaisingh

Is your feature request related to a problem? Please describe.

It seems there is no support for running multiple Tuono applications under a single domain name with different subpaths using Nginx.

Describe the solution you'd like

I am trying to run different Tuono applications under a single domain name and route specific subpaths to specific Tuono projects. Here is what I mean:

  • www.example.com/: should render the content served by the project running on port 3000.
  • www.example.com/about-us: should still render from the project running on port 3000.
  • www.example.com/project/project-1: should render the content served by the project running on port 3001.
  • www.example.com/project/project-2: should render the content served by the project running on port 3002.

Consider this Nginx configuration file as an example:

# HTTP -> redirect to HTTPS
server {
    listen 80;
    listen [::]:80;

    server_name example.com www.example.com;

    return 301 https://$host$request_uri;
}

# HTTPS server
server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name example.com www.example.com;

    ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    include /etc/letsencrypt/options-ssl-nginx.conf;
    ssl_dhparam         /etc/letsencrypt/ssl-dhparams.pem;

    location / {
        proxy_pass         http://localhost:3000;
        proxy_http_version 1.1;

        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;
    }

    location /projects/project-1 {
        proxy_pass         http://localhost:3001/;
        proxy_http_version 1.1;

        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;
    }

    location /projects/project-2 {
        proxy_pass         http://localhost:3002/;
        proxy_http_version 1.1;

        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;
    }
}

The issue is that the /projects/project-2 request is being processed by all three Tuono servers.

Describe alternatives you've considered

An alternative solution is to run the Tuono projects—other than the one running on port 3000 (which can be considered the main project)—on subdomains. For example: project1.example.com.

This is not exactly what I want, but it is workable until there is a proper way to route specific subpaths to specific Tuono projects.

Additional context

If I am wrong and there is a working way to route specific subpaths to specific Tuono projects, I would appreciate being corrected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions