Score:0

Can you have multi proxy as location in nginx conf?

rw flag

I have several web apps I like to proxy with a single URL. This is my nginx.conf

server {
    listen 443 ssl;

    server_name webapps.mysite.com 192.168.5.28;

    access_log  /var/log/nginx/webapps_access.log;
    error_log   /var/log/nginx/webapps_errors.log;

    ssl_certificate /etc/letsencrypt/live/webapps.mysite.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/webapps.mysite.com/privkey.pem; # managed by Certbot


    location /casaos {
        proxy_pass http://192.168.5.165:81;
        proxy_intercept_errors on;
        proxy_buffering off;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $http_connection;
        # access_log off;

    }

    location /guacamole/ {
        proxy_pass http://192.168.5.44:8080;
        proxy_intercept_errors on;
        proxy_buffering off;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $http_connection;
        # access_log off;
    }

    location /apps {
        # The following configurations must be configured when proxying to Kasm Workspaces

        # WebSocket Support
        proxy_set_header        Upgrade $http_upgrade;
        proxy_set_header        Connection "upgrade";

        # Host and X headers
        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;

        # Connectivity Options
        proxy_http_version      1.1;
        proxy_read_timeout      1800s;
        proxy_send_timeout      1800s;
        proxy_connect_timeout   1800s;
        proxy_buffering         off;
        proxy_intercept_errors on;

        # Allow large requests to support file uploads to sessions
        client_max_body_size 10M;

        # Proxy to Kasm Workspaces running locally on 8443 using ssl
        proxy_pass https://192.168.5.40;
    }
}

If I use the ip's of the webapps they work;

HTTP://192.168.5.165:81

HTTP://192.168.4.44:8080

HTTP://192.168.5.40

but in my site config, only site that works is the guacamole app works.

HTTP://webapps.mysite.com/guacamole/

The other gives me a 404.

HTTP://webapps.mysite.com/apps

HTTP://webapps.mysite.com/casaos

How can I troubleshoot why I am getting 404? The logs are giving me nothing either, I only my tries accessing my site

One more thing, if I only proxy only one web as a /, they work.

location / {
    proxy_pass http://192.168.5.165:81;
    proxy_intercept_errors on;
    proxy_buffering off;
    proxy_http_version 1.1;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;
    # access_log off;

}

So this again is bugging me that I can host multi-web apps.

Richard Smith avatar
jp flag
Try adding a trailing `/` to the end of the `location` and `proxy_path` directives. For example: `location /casaos/ { proxy_pass http://192.168.5.165:81/; ... }`
terrorpup avatar
rw flag
I've tried that as well, still getting the 404 error. Thanks. It's why I asked if there's way to troubleshoot the proxy. Would setting the logs to debug help?
terrorpup avatar
rw flag
Ok, I am getting close. I went ahead and made Kasm Web proxy on /, as I stated earlier that works. I am fine with that. CasaOS started to return a white page, now my issue appears to be javascript <noscript> <strong>We're sorry but CasaOS doesn't work properly without JavaScript enabled. Please enable it to continue.</strong> </noscript>
us flag
You need to look at the upstream application logs to see which URL is actually requested.
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.