Skip to content

nginx reverse proxy path issue #5284

@hacknus

Description

@hacknus

Problem

Hello, first of all thanks a lot to the devs for this amazing framework!

I am serving two dioxus webpages behind a reverse proxy:

url:443 -> website A on port 8080
url:443/websiteb -> website B on port 8081

now website A works fine. But website B always points the assets to url/assets instead of url/websiteb/assets

I'm not sure if this is related to #4240.

Steps To Reproduce

Steps to reproduce the behavior:

nginx config:

location /websiteb/ {

        proxy_connect_timeout 60;

        proxy_read_timeout 60;

        proxy_send_timeout 60;

        proxy_intercept_errors off;

        proxy_http_version 1.1;

        proxy_set_header        Upgrade            $http_upgrade;

        proxy_set_header        Connection            $connection_upgrade;

        proxy_set_header        Host            $http_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;

        proxy_pass http://192.168.1.115:8081;

    }

    location / {

        proxy_connect_timeout 60;

        proxy_read_timeout 60;

        proxy_send_timeout 60;

        proxy_intercept_errors off;

        proxy_http_version 1.1;

        proxy_set_header        Upgrade            $http_upgrade;

        proxy_set_header        Connection            $connection_upgrade;

        proxy_set_header        Host            $http_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;

        proxy_pass http://192.168.1.115:8080;

    }

Dioxus.toml
the base_path gets ignored, it does not matter if put it in or not:

[application]

[web.app]

# HTML title tag content
title = "websiteb"
base_path = "websiteb"

# include `assets` in web platform
[web.resource]
static_dir = "assets"

# Additional CSS style files
style = []

# Additional JavaScript files
script = []

[web.resource.dev]

# Javascript code file
# serve: [dev-server] only
script = []

and main.rs

//
// ================= SERVER MAIN =================
//
#[cfg(feature = "server")]
#[tokio::main]
async fn main() {
    use axum::Router;
    use std::net::SocketAddr;
    dotenv::dotenv().ok();

    start_tabs_reload_task();

    let port = std::env::var("PORT")
        .ok()
        .and_then(|p| p.parse::<u16>().ok())
        .unwrap_or(8081);

    let addr = SocketAddr::from(([0, 0, 0, 0], port));
    println!("Listening on http://{}", addr);

    let router = Router::new().serve_dioxus_application(ServeConfig::default(), App);

    let listener = tokio::net::TcpListener::bind(&addr).await.unwrap();

    axum::serve(listener, router).await.unwrap();
}

//
// ================= WASM MAIN =================
//
#[cfg(not(feature = "server"))]
fn main() {
    dioxus::launch(App);
}

Expected behavior

That it is possible to link to the assets on the same path

Environment:

  • Dioxus version: 0.7.3
  • Rust version: 1.92.0
  • OS info: macOS, trixie docker
  • App platform: web

Questionnaire

I'm interested in fixing this myself but don't know where to start.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions