Skip to content

website/docs: Enhance reverse proxy NGINX configuration - #27774

Merged
BeryJu merged 4 commits into
goauthentik:mainfrom
michellao:patch-1
Nov 12, 2026
Merged

BeryJu merged 4 commits into
goauthentik:mainfrom
michellao:patch-1

Conversation

@michellao

Copy link
Copy Markdown
Contributor

Details

What does this PR change?

Separate location static assets and websockets for authentik on NGINX configuration. Also fixing missing Host on websocket and some /static paths. Because I've customise the external port and on the browser gets redirect to https://authentik.

Why is this change needed?

How was this tested?

Linked issues


Checklist

  • The project has been linted, built, and tested (make all)
  • The documentation has been updated and formatted (make docs)

By adding it does fix missing Host on websocket and some /static paths. Because I've customise the external port and on the browser gets redirect to https://authentik.

Signed-off-by: Michel Lao <[email protected]>
@michellao
michellao requested a review from a team as a code owner November 11, 2026 15:08
@netlify

netlify Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

👷 Deploy request for authentik-storybook accepted.

Name Link
🔨 Latest commit 37f744c
🔍 Latest deploy log https://app.netlify.com/projects/authentik-storybook/deploys/6af484de4e6b981f3d723805

@netlify

netlify Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-integrations ready!

Name Link
🔨 Latest commit ce4c05c
🔍 Latest deploy log https://app.netlify.com/projects/authentik-integrations/deploys/6af4f37a7b33b0b9909248b1
😎 Deploy Preview https://deploy-preview-27774--authentik-integrations.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for authentik-docs ready!

Name Link
🔨 Latest commit 2f12807
🔍 Latest deploy log https://app.netlify.com/projects/authentik-docs/deploys/6af4cd59fd4b6e3da9aab022
😎 Deploy Preview https://deploy-preview-27774--authentik-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@dominic-r
dominic-r requested a review from BeryJu November 11, 2026 15:46
@codecov

codecov Bot commented Nov 11, 2026 •

Copy link
Copy Markdown

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
1 1 0 0
View the top 1 failed test(s) by shortest run time
tests.openid_conformance.test_oidc_frontchannel.TestOpenIDConformanceFrontchannel::test_oidcc_frontchannel_logout_certification_test_plan
Stack Traces | 52.1s run time
self = <unittest.case._Outcome object at 0x7b7829f41e80>
test_case = <tests.openid_conformance.test_oidc_frontchannel.TestOpenIDConformanceFrontchannel testMethod=test_oidcc_frontchannel_logout_certification_test_plan>
subTest = False

    @contextlib.contextmanager
    def testPartExecutor(self, test_case, subTest=False):
        old_success = self.success
        self.success = True
        try:
>           yield

.../hostedtoolcache/Python/3.14.10........./x64/lib/python3.14/unittest/case.py:58: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.openid_conformance.test_oidc_frontchannel.TestOpenIDConformanceFrontchannel testMethod=test_oidcc_frontchannel_logout_certification_test_plan>
result = <TestCaseFunction test_oidcc_frontchannel_logout_certification_test_plan>

    def run(self, result=None):
        if result is None:
            result = self.defaultTestResult()
            startTestRun = getattr(result, 'startTestRun', None)
            stopTestRun = getattr(result, 'stopTestRun', None)
            if startTestRun is not None:
                startTestRun()
        else:
            stopTestRun = None
    
        result.startTest(self)
        try:
            testMethod = getattr(self, self._testMethodName)
            if (getattr(self.__class__, "__unittest_skip__", False) or
                getattr(testMethod, "__unittest_skip__", False)):
                # If the class or method was skipped.
                skip_why = (getattr(self.__class__, '__unittest_skip_why__', '')
                            or getattr(testMethod, '__unittest_skip_why__', ''))
                _addSkip(result, self, skip_why)
                return result
    
            expecting_failure = (
                getattr(self, "__unittest_expecting_failure__", False) or
                getattr(testMethod, "__unittest_expecting_failure__", False)
            )
            outcome = _Outcome(result)
            start_time = time.perf_counter()
            try:
                self._outcome = outcome
    
                with outcome.testPartExecutor(self):
>                   self._callSetUp()

.../hostedtoolcache/Python/3.14.10........./x64/lib/python3.14/unittest/case.py:665: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.openid_conformance.test_oidc_frontchannel.TestOpenIDConformanceFrontchannel testMethod=test_oidcc_frontchannel_logout_certification_test_plan>

    def _callSetUp(self):
>       self.setUp()

.../hostedtoolcache/Python/3.14.10........./x64/lib/python3.14/unittest/case.py:612: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.openid_conformance.test_oidc_frontchannel.TestOpenIDConformanceFrontchannel testMethod=test_oidcc_frontchannel_logout_certification_test_plan>

    def setUp(self):
>       super().setUp()

tests/openid_conformance/test_oidc_frontchannel.py:10: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<tests.openid_conformance.test_oidc_frontchannel.TestOpenIDConformanceFrontchannel testMethod=test_oidcc_frontchannel_logout_certification_test_plan>,)
kwargs = {}

    @wraps(func)
    def wrapper(*args, **kwargs):
        for file in files:
            content = BlueprintInstance(path=file).retrieve()
            Importer.from_string(content).apply()
>       return func(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^

.../blueprints/tests/__init__.py:25: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<tests.openid_conformance.test_oidc_frontchannel.TestOpenIDConformanceFrontchannel testMethod=test_oidcc_frontchannel_logout_certification_test_plan>,)
kwargs = {}

    @wraps(func)
    def wrapper(*args, **kwargs):
        for file in files:
            content = BlueprintInstance(path=file).retrieve()
            Importer.from_string(content).apply()
>       return func(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^

.../blueprints/tests/__init__.py:25: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<tests.openid_conformance.test_oidc_frontchannel.TestOpenIDConformanceFrontchannel testMethod=test_oidcc_frontchannel_logout_certification_test_plan>,)
kwargs = {}

    @wraps(func)
    def wrapper(*args, **kwargs):
        for file in files:
            content = BlueprintInstance(path=file).retrieve()
            Importer.from_string(content).apply()
>       return func(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^

.../blueprints/tests/__init__.py:25: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<tests.openid_conformance.test_oidc_frontchannel.TestOpenIDConformanceFrontchannel testMethod=test_oidcc_frontchannel_logout_certification_test_plan>,)
kwargs = {}

    @wraps(func)
    def wrapper(*args, **kwargs):
        config = apps.get_app_config(app_name)
        if isinstance(config, ManagedAppConfig):
            config._on_startup_callback(None)
>       return func(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^

.../blueprints/tests/__init__.py:43: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

args = (<tests.openid_conformance.test_oidc_frontchannel.TestOpenIDConformanceFrontchannel testMethod=test_oidcc_frontchannel_logout_certification_test_plan>,)
kwargs = {}

    @wraps(func)
    def wrapper(*args, **kwargs):
        for file in files:
            content = BlueprintInstance(path=file).retrieve()
            Importer.from_string(content).apply()
>       return func(*args, **kwargs)
               ^^^^^^^^^^^^^^^^^^^^^

.../blueprints/tests/__init__.py:25: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.openid_conformance.test_oidc_frontchannel.TestOpenIDConformanceFrontchannel testMethod=test_oidcc_frontchannel_logout_certification_test_plan>

    @apply_blueprint(
        "default/flow-default-authentication-flow.yaml",
        "default/flow-default-invalidation-flow.yaml",
    )
    @apply_blueprint(
        "default/flow-default-provider-authorization-implicit-consent.yaml",
        "default/flow-default-provider-invalidation.yaml",
    )
    @apply_blueprint("system/providers-oauth2.yaml")
    @reconcile_app("authentik_crypto")
    @apply_blueprint("testing/oidc-conformance.yaml")
    def setUp(self):
>       super().setUp()

tests/openid_conformance/base.py:32: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.openid_conformance.test_oidc_frontchannel.TestOpenIDConformanceFrontchannel testMethod=test_oidcc_frontchannel_logout_certification_test_plan>

    def setUp(self):
>       super().setUp()

tests/live.py:71: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.openid_conformance.test_oidc_frontchannel.TestOpenIDConformanceFrontchannel testMethod=test_oidcc_frontchannel_logout_certification_test_plan>

    def setUp(self):
        super().setUp()
>       self.driver = self._get_driver()
                      ^^^^^^^^^^^^^^^^^^

tests/selenium.py:43: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <tests.openid_conformance.test_oidc_frontchannel.TestOpenIDConformanceFrontchannel testMethod=test_oidcc_frontchannel_logout_certification_test_plan>

    def _get_driver(self) -> WebDriver:
        count = 0
        opts = webdriver.ChromeOptions()
        opts.accept_insecure_certs = True
        opts.add_argument("--disable-search-engine-choice-screen")
        opts.add_extension(self._get_chrome_extension())
        # This breaks selenium when running remotely...?
        # opts.set_capability("goog:loggingPrefs", {"browser": "ALL"})
        opts.add_experimental_option(
            "prefs",
            {
                "profile.password_manager_leak_detection": False,
            },
        )
        while count < RETRIES:
            try:
                driver = webdriver.Remote(
                    command_executor="http://localhost:4444/wd/hub",
                    options=opts,
                )
                driver.maximize_window()
                return driver
            except WebDriverException as exc:
                self.logger.warning("Failed to setup webdriver", exc=exc)
                count += 1
>       raise ValueError(f"Webdriver failed after {RETRIES}.")
E       ValueError: Webdriver failed after 3.

tests/selenium.py:72: ValueError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@dominic-r dominic-r left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! I don't think we should merge this as is. The current example already sets Host $http_host (which keeps a custom external port) and handles WebSocket upgrades on every path, so I'm not sure what broke in your setup. Could you share the config that redirected you to https://authentik?

A few problems with the split:

  • Removing Connection $connection_upgrade_keepalive from location / makes nginx send Connection: close upstream, so the keepalive in the upstream block stops working.
  • Limiting upgrades to location /ws breaks installs under a subpath (AUTHENTIK_WEB__PATH), and /ws without a trailing slash matches more than intended.
  • The /static block repeats / without adding anything.

If X-Forwarded-Host fixed something for you, adding that one header to the existing location / would be a smaller change we can look at.

@michellao

Copy link
Copy Markdown
Contributor Author
upstream authentik {
    server [::1]:9443;
    # Improve performance by keeping some connections alive.
    keepalive 10;
}

server {
    listen      30016 ssl;
    listen      30016 quic;
    listen      [::]:30016 ssl;
    listen      [::]:30016 quic;
    server_name example.com;

    location / {
        proxy_pass https://authentik;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Host $http_host;
        #proxy_set_header Host $http_host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection $connection_upgrade;
    }
}

With this configuration, my browser requests to https://authentik
Here a screenshot on Chromium with network console.

image

Endpoints which point to https://authentik:

  • /static/dist/assets/images/flow_background.jpg
  • /ws/client/
  • /api/v3/flows/executor/default-authentication-flow/?query=next%3D%252F

Also when X-Forwarded-Host and Host headers are sets, the app doesn't receive any host header and I receive the missing host header message.

That why I end up with this configuration.

@dominic-r

Copy link
Copy Markdown
Member

Thanks, that explains it. With the Host line commented out, nginx sends authentik as the host, so the URLs point to https://authentik.

The missing host error is probably HTTP/3: browsers on quic don't send a Host header, so $http_host ends up empty. Can you try proxy_set_header Host $host:$server_port; and see if that works?

If that's the case, could you change this PR to only update the Host line in the existing location / block, and drop the location split?

Removed redundant proxy settings for static assets and websocket locations.

Signed-off-by: Michel Lao <[email protected]>
@dominic-r

Copy link
Copy Markdown
Member

FYI: This changes the host for everyone, not just HTTP/3 setups. Could you keep Host $http_host and drop the X-Forwarded-Host line, and add a comment above it saying to use $host:$server_port when quic is enabled?

@michellao

Copy link
Copy Markdown
Contributor Author

Thanks for your help. I just discover this difference between HTTP/2 and HTTP/3.

@dominic-r dominic-r left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've pushed up a commit. I'll approve and get this merged. Thanks for your contribution!

@dominic-r
dominic-r enabled auto-merge (squash) November 11, 2026 23:02
@dominic-r
dominic-r disabled auto-merge November 11, 2026 23:51
@dominic-r
dominic-r enabled auto-merge (squash) November 11, 2026 23:51
@BeryJu
BeryJu disabled auto-merge November 12, 2026 11:44
@BeryJu
BeryJu merged commit e9f07f1 into goauthentik:main Nov 12, 2026
386 of 387 checks passed
kensternberg-authentik added a commit that referenced this pull request Nov 12, 2026
* main: (35 commits)
  providers/saml: share xml signature generation (#27786)
  tests/openid_conformance: upload JPEG screenshots (#27749)
  crypto: export certificate expiry as a Prometheus metric (#27771)
  core: bump openapitools/openapi-generator-cli from v7.26.0 to v7.27.0 in /packages/client-ts (#27663)
  core: bump openapitools/openapi-generator-cli from v7.26.0 to v7.27.0 in /packages/client-rust (#27662)
  core: bump goauthentik/fips-debian from `d363011` to `16c391c` in /lifecycle/container (#27368)
  web: bump body-parser from 1.20.6 to 1.20.9 (#27521)
  core: bump library/node from `6d2c7d5` to `438603b` in /website (#27709)
  core: bump library/nginx from `5ab5b0b` to `165ddde` in /website (#27710)
  web: bump postcss-selector-parser from 7.1.7 to 7.2.0 in /web (#27742)
  web: bump glob from 13.0.6 to 13.0.7 (#27744)
  web: bump colord from 2.10.0 to 2.11.0 (#27745)
  web: bump colord from 2.10.0 to 2.11.0 in /website (#27746)
  root: resolve squashed migrations' dependencies (#27751)
  ci: add django-migration-linter (#27748)
  core: bump deepmerge from 3.0.1 to 4.0.0 (#27767)
  website/docs: Enhance reverse proxy NGINX configuration (#27774)
  providers/oauth2: drop the GrantTypes session alias (#27788)
  website/integrations: add calendarbridge (#27779)
  website/integrations: add onecal (#27778)
  ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants