Search code examples
linuxproxyapache2reverse-proxyproxypass

Need to proxy to dynamic ports


I use the gameserver panel pterodactyl.io. There I want to host Sinusbot, which has a web interface. Of course, all servers have different ports, and every new server gets another port. I'd like to redirect URLs like: https://example.com/1234 to http://localhost:1234. Unfortunately, I have no idea how I can realize this with apache2 -.-


Solution

  • This is actually quite simple with mod_rewrite

    RewriteEngine ON
    RewriteRule ^/?(\d+)$ http://localhost:$1/ [P]
    
    Header edit Location http://localhost:(\d)/(.*) http://example.com/$1/$2