Score:0

Nginx - Reverse proxy serving ScreenConnect does not prepend subdirectory

cn flag

I am running an unsecured ScreenConnect web interface on a machine on my local network. I would like to serve it through port 443 using nginx's reverse proxy, and access it via:
https://<WAN.IP.ADDRESS>/screenconnect

My nginx.conf location block:

            location / {
            root /www/var/nginx/html
            }

            location /screenconnect/ {
            proxy_pass                              http://local.screenconnect.server:8040/;
            proxy_buffering                         off;
            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;
            }

I am successful in getting to the Screen Connect Web Interface, and the url reads as
https://<WAN.IP.ADDRESS>/screenconnect/

However, any additional subdirectories that I access, such as https://<WAN.IP.ADDRESS>/screenconnect/login.php? will drop the /screenconnect/ subdirectory and try to access https://<WAN.IP.ADDRESS>/login.php?
This throws me a 404 error.

Things I've tried

  • I've inserted /screenconnect/ to https://<WAN.IP.ADDRESS>/login.php?/ and got https://<WAN.IP.ADDRESS>/screenconnect/login.php?, which gives me the site I need.
  • I've adjusted the web.config file on my screenconnect server and appended the correct directory:
    <add key="WebServerAddressableUri" value="https://WAN.IP.ADDRESS:443/screenconnect/" />
  • I've tried removing the / at the end of proxy_pass http://local.screenconnect.server:8040/; and location /screenconnect/
  • I've also tried a host of different simple directives for the location block from people who have had related problems
  • I've replaced the IP of the screenconnect server with an apache server running on port 80 that has a simple html page, which redirects to a subfolder. When redirecting, the /screenconnect/ directory is prepended correctly.
djdomi avatar
za flag
I believe that the application is doing this behavior due a miss or wrong configuration. I'm unfamiliar with rewrite of nginx but it might have a chance
Ivan Shatsky avatar
gr flag
Generally it is the ScreenConnect (or any upstream web app) job, to generate its links including the correct URI prefix. The only available info about this subject I found so far is [about](https://kimconnect.com/screenconnect-and-nginx/) the `WebServerAddressableUri` parameter which you already tried to adjust with no luck; unfortunally looks like the support forums are dead now. You can check the [How to handle relative urls correctly with a nginx reverse proxy](https://serverfault.com/questions/932628/how-to-handle-relative-urls-correctly-with-a-nginx-reverse-proxy) ServerFault thread.
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.