bugy / script-server

Web UI for your scripts with execution management
Other
1.59k stars 247 forks source link

Reverse proxy w/Caddy v2 #704

Closed aurelg closed 11 months ago

aurelg commented 11 months ago

Hi @bugy, and thank you for this projet, it's just so useful! :pray:

I'm trying to deploy a script-server behind a caddy v2 reverse proxy. I had a look at the wiki, which describes the configurations for nginx and apache, but I failed to translate into a Caddyfile (reverse_proxy documentation).

Here's the configuration I have:

reverse_proxy 127.0.0.1:5001 {
    # the following are required?
    # https://caddy.community/t/caddy-v2-how-to-proxy-websoket-v2ray-websocket-tls/7040/8
    header_up Host {host}
    header_up X-Real-IP {remote_host}
    header_up X-Forwarded-For {remote_host}
    header_up X-Forwarded-Proto {scheme}

    # Seems to be required? https://github.com/bugy/script-server/issues/406
    header_up X-Scheme {scheme}

    # generated by chatGPT from the nginx configuration
    header_up Connection *Upgrade*
    header_up Origin http://{remote_host}
}

The login page works, but my browser consoles complain they cannot connect to wss://..., and I have the following error message in red:

Failed to load script info. Try to reload the page. Error message:
Failed to connect to the server

PS: I noticed #406 which in the end seemed to work with a much simpler configuration, but it actually did not.

aurelg commented 11 months ago

My bad, the very simple snippet below works well:

  reverse_proxy 127.0.0.1:5000 {
    header_up X-Scheme {scheme}
  }

@bugy Would it be worth adding to the wiki?

bugy commented 11 months ago

Hi @aurelg yes, I will add it to wiki, thank you!

bugy commented 11 months ago

Could you share your final configuration, please?

aurelg commented 11 months ago

Sure ! The final configuration to have script-server reverse-proxied to serve https://example.com is:

example.com {
  reverse_proxy 127.0.0.1:5000 {
    header_up X-Scheme {scheme}
  }
}

No need for more, caddy's configuration is extremely concise.

bugy commented 11 months ago

Wow, that's really small. I added it to wiki, thanks!