EdyTheCow / docker-pterodactyl

Running Pterodactyl Panel inside docker containers behind Traefik reverse proxy
234 stars 49 forks source link

Cross-Origin and XHR Error #13

Closed fenpaws closed 3 years ago

fenpaws commented 3 years ago

Hey there, I used your really good repo to set up my own little pterodactyl server. Since I already had a Treafeik setup I just adopted the config you wrote. It seems to work fine, Panel is working and if I access the wings directly I also get a JSON response.

But if I check the Panel again for the WIngs it's offline, after a quick look in the console I noticed that it gave me a huge amount of Cross-ORigin and XHR errors.

It seems that it trys to access the API of the Wing with https://wings.fenpa.ws:80/api/system. It should not add the :80 right? did I mess something up?

The auto-redirect works fine for any service I have.

I added two screenshots, if you need more info then I'm more than happy to reply.

grafik grafik
EdyTheCow commented 3 years ago

Hey! I am glad you found my repository useful :) what did you put as port for wings when setting it up in the panel? It seems like it's trying to access it using port 80 which is HTTP, since your wings is running HTTPS with default port it should be accessing 443 instead of 80.

fenpaws commented 3 years ago

Wow, you are fast o.0

I did set up the wings to use port 80, as you stated in your Installation. But if I use 443 I just get a bad gateway error on the wing.

But I had an idea, if you set up the Wing in the Panel to use port 443, and change the copied config to use port 80 instead of port 443 for the API then it works.

api:
  host: 0.0.0.0
  port: 80
  ssl:
    enabled: false
    cert: /etc/letsencrypt/live/wings.vm.fenpa.ws/fullchain.pem
    key: /etc/letsencrypt/live/wings.vm.fenpa.ws/privkey.pem
  disable_remote_download: false
  upload_limit: 100
grafik grafik

Side note:

That is the my wings.toml config for traefik:

[http]
  [http.routers]
    [http.routers.pterodactyl-wings]
    rule = "Host(`wings.vm.fenpa.ws`)"
    service = "pterodactyl-wings"
    entryPoints  = ["web"]
    middlewares = ["redirect-to-https"]

    [http.routers.pterodactyl-wings_ssl]
    rule = "Host(`wings.vm.fenpa.ws`)"
    service = "pterodactyl-wings"
    entryPoints  = ["websecure"]
        [http.routers.pterodactyl-wings_ssl.tls]
            certResolver = "letsencrypt"

[http.services]
    [http.services.pterodactyl-wings]        
        [http.services.pterodactyl-wings.loadBalancer]
            [[http.services.pterodactyl-wings.loadBalancer.servers]]
                url = "http://192.168.178.49"

[http.middlewares]
    [http.middlewares.redirect-to-https.redirectScheme]
    scheme = "https"
EdyTheCow commented 3 years ago

Interesting, the only thing I can think of is there's something going on with the redirects. In my setup I normally let cloudflare handle the redirect from HTTP to HTTPS which is why it may of worked using port 80 in the guide. I've never tested letting traefik do the redirects which is why I may not of encountered this issue. I am glad you got it to work and thank you for doing some debugging, I'll test this myself to confirm my theory and update the guide in the future :)

fenpaws commented 3 years ago

awesome, im glad that i could help you out. Maybe this helpy oter people too :D

EdyTheCow commented 3 years ago

Issues reported here were now addressed in the latest commit. The instructions / guide will be updated soon since big parts of the setup structure was changed. The updated setup was tested and is currently running in production environment.