#CORS issue? Using Caddy as a reverse proxy for panel and wings.

17 messages · Page 1 of 1 (latest)

unkempt orbitBOT
#

There were too many logs to read @jade forge. Please post 5 or less.

jade forge
#

Hello!
I got pterodactyl panel up and running, but i am having difficulties with wings. The panel and wing in question are on two different Proxmox LXC's, so essentially act as different computers in the local network. I am using Caddy to reverse proxy both using automatic SSL. My urls are configured as such:
pterodactyl.mydomain.com
wing1.mydomain.com

443, 80, 8080 and 2022 are all port forwarded to my reverse proxy, which has the following Caddyfile

pterodactyl.mydomain.com {
    reverse_proxy {
        dynamic a pterodactyl.mydomain.internal 80
        header_up Host {host}
        header_up X-Real-IP {remote}
    }
}
wing1.mydomain.com {
    reverse_proxy {
        dynamic a wing1.mydomain.internal
    }
}

my wings config is as such:

debug: false
uuid: someuuid
token_id: sometoken
token: sometoken
api:
  host: 0.0.0.0
  port: 8080
  ssl:
    enabled: false
    cert: /etc/letsencrypt/live/wing1.mydomain.com/fullchain.pem
    key: /etc/letsencrypt/live/wing1.mydomain.com/privkey.pem
  upload_limit: 100
system:
  data: /var/lib/pterodactyl/volumes
  sftp:
    bind_port: 2022
allowed_mounts: []
remote: 'https://pterodactyl.mydomain.com'

I am getting the following error in my browser:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://wing1.mydomain.com:8080/api/system. (Reason: CORS request did not succeed). Status code: (null).

I have tried adding a header_down to my reverse_proxy directives as such, to no avail:

Control-Allow-Origin: *

at this point i feel like im a bit out of my league, im not sure what im doing wrong. Ive seen a github issue that might be related get solved, maybe theres some config within pterodactyl itself? does anyone have any leads?

unkempt orbitBOT
#

There were too many logs to read @jade forge. Please post 5 or less.

jade forge
#

i dont understand, ive not posted more than 5?

ember summit
#

Can you reach that wing1 url in your browser at all?

#

Ignore the bot response. It's just picking up more than 5 fqdns, and it's unhappy

jade forge
#

hmm, internal address works but as you might have guessed, my caddy might not be forwarding stuff

ember summit
jade forge
#

oh, should update here.

Pretty sure caddy was working correctly, and cross origin thingy wont work. When i change my reverse proxy such that:

pterodactyl.mydomain.com {
    reverse_proxy {
        dynamic a pterodactyl.mydomain.internal 80
        header_up Host {host}
        header_up X-Real-IP {remote}
    }
}
pterodactyl.mydomain.com:8080 {
    reverse_proxy {
        dynamic a wing1.mydomain.internal 8080
        header_up Host {host}
        header_up X-Real-IP {remote}
    }
}
pterodactyl.mydomain.com:2022 {
    reverse_proxy {
        dynamic a wing1.mydomain.internal 2022
        header_up Host {host}
        header_up X-Real-IP {remote}
    }
}

and ofcourse, change the eq stuff in the node settings, it works

#

here, i swapped wing1 for pterodactyl. Essentially just an internal port forward where ssl goes to panel and 8080 + 2022 goes to wing. If i keep it like this ill need separate ports for each wings instance, which is suboptimal since id rather just change the subdomain for different wings LXC's.

#

for claritys sake, 80, 443, 8080 and 2022 are all port forwarded to my reverse proxy

river herald
#

Hey, were you able to get it to work @jade forge ?

I probably got the exact same (or at least a very similar) problem
my caddy config:

(cors) {
    @origin header Origin {args[0]}
    header @origin Access-Control-Allow-Origin "{args[0]}"
    header @origin Access-Control-Allow-Methods "OPTIONS,HEAD,GET,POST,PUT,PATCH,DELETE"
}

pterodactyl-wings-1.shork.ch {
     import cors "https://pterodactyl.shork.ch"
    reverse_proxy 10.99.0.3:9001
}

Well, adding the headers just changed the error message in my browser from CORS Missing Allow (this makes sense imo) to CORS Preflight Did Not Succeedcadd

dense bough
#

Ooh, i think i ran into this ages ago
I was never able to fix it :c ptero just hated dealing with CORS, i think in the end i just ended up forwarding each wing on a dedicated port, and not proxying them. it was what the discord recomended at the time, not sure if its still the best

jade forge
dense bough
#

Yeah, we're in the same boat. I would have thought that using subdomains thru a proxy would be a more common setup but i guess not. Do most ppl host their wings offsite or on a vps?
When you only have one public IP to use, its trickier!

jade forge
#

Well you can still proxy, just not via subdomains. I still have caddy redirect pterodactyl.mydomain.com, but route depends on port. Granted, i could just do the port forward in my router, but i use hostnames internally so i dont need to bother with IP's, which my router doesnt support for port forwarding. Hence, my use of caddy. Its a bit strange, but it consolidates more of my setup in one place. Really sad i cant just use 1 port but thats alright. I need to open specific ports for the actual gameserver either way.

dense bough
#

Yeah :c