NixOS / nixpkgs

Nix Packages collection & NixOS
MIT License
18.11k stars 14.15k forks source link

Pretix gives "Unknown Host" error #332779

Closed Radvendii closed 3 months ago

Radvendii commented 3 months ago

Describe the bug

When using the pretix module, we're getting an "Unknown Host" page. All requests get logged as "bad request". I found this issue, and the first comment under it pointed to the Host header nginx is sending to pretix.

Adding the following fixes the problem, but I don't know enough about pretix or nginx to say whether this should be added to the pretix module, or if it's something specific to our setup.

services.nginx.virtualHosts.${services.pretix.nginx.domain} = {
  locations."/".extraConfig = ''
    proxy_set_header Host $host;
  '';
};

The configuration is private. I can make a minimal reproduction of the problem if that's helpful, but I figured before I put in that effort the maintainer might understand what's going on just from this much.

notify maintianers

@mweinelt


Add a :+1: reaction to issues you find important.

mweinelt commented 3 months ago

Have you set services.pretix.nginx.domain?

Radvendii commented 3 months ago

Yes

mweinelt commented 3 months ago

And services.pretix.settings.pretix.url? Basically what you need is


services.pretix = {
  nginx.domain = "tickets.example.com";
  settings.pretix.url = "https://tickets.example.com";
};
Radvendii commented 3 months ago

Yep, that's set to the right thing too. We basically have

let
  hostName = tickets.example.com;
in
services.pretix = {
  nginx.domain = hostName;
  settings.pretix.url = "https://${hostName}";
};

And navigating to https://<hostName> clearly connects to pretix, since we get the unknown hostname page from pretix. I also checked the generated pretix config file and it has the [pretix] section with url=https://<hostName> set

mweinelt commented 3 months ago

How about recommendedProxySettings?

Radvendii commented 3 months ago

That's the one. We have it disabled :woman_facepalming:

Thanks, sorry for the noise!