mirror of
https://github.com/authelia/authelia.git
synced 2026-10-28 09:34:52 +08:00
This adds the official OpenID Connect 1.0 Conformance Suites used by the OpenID Foundation to assert conformance for certification to our test suites. This allows us to offer the quality guarantee that every single commit of Authelia conforms to the OpenID Connect 1.0 and related specifications. The tests allow the following results to indicate success automatically: `PASSED`, `REVIEW` (result that manual review must occur), `SKIPPED` (result that indicates the conformance test is not needed due to reasonable criteria). In addition only the `FINISHED` status is accepted. If the result is `WARNING` which is just an informative result which does not indicate lack of conformance it can be manually allowed on a per module basis with an explanation. This allows both detecting new `WARNING` results and necessitates documenting them for future improvements. All of the result and status checks align entirely with the standard conformance certification process, ensuring that each commit would be certifiable. The storage for the suites is able to be configured for persistence, and every plan created carries the commit sha or tag; allowing for historical evidence of conformance.
642 lines
30 KiB
Nginx Configuration File
642 lines
30 KiB
Nginx Configuration File
# SPDX-FileCopyrightText: 2026 Authelia
|
|
#
|
|
# SPDX-License-Identifier: Apache-2.0
|
|
|
|
#
|
|
# You can find a documented example of configuration in ./docs/proxies/nginx.md.
|
|
#
|
|
worker_processes 1;
|
|
events {
|
|
worker_connections 1024;
|
|
}
|
|
|
|
http {
|
|
map $http_host $port_suffix {
|
|
"~:(?<port>\d+)$" ":$port";
|
|
default "";
|
|
}
|
|
|
|
server {
|
|
listen 8080 ssl;
|
|
server_name ~^login\.example([0-9])*\.com$;
|
|
|
|
resolver 127.0.0.11 ipv6=off;
|
|
set $frontend_endpoint http://authelia-frontend:3000;
|
|
set $backend_endpoint https://authelia-backend:9091;
|
|
set $metrics_endpoint http://authelia-backend:9959;
|
|
|
|
ssl_certificate /pki/public.chain.pem;
|
|
ssl_certificate_key /pki/private.pem;
|
|
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
|
|
error_page 497 301 =307 https://$host:$server_port$request_uri;
|
|
|
|
# Serve the backend API for the portal.
|
|
location /api {
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
# Required by Authelia because "trust proxy" option is used.
|
|
# See https://expressjs.com/en/guide/behind-proxies.html
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
# Required by Authelia to build correct links for identity validation.
|
|
proxy_set_header X-Forwarded-Host $host$port_suffix;
|
|
proxy_set_header X-Forwarded-URI $request_uri;
|
|
|
|
# Needed for network ACLs to work. It appends the IP of the client to the list of IPs
|
|
# and allows Authelia to use it to match the network-based ACLs.
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_intercept_errors on;
|
|
|
|
proxy_pass $backend_endpoint;
|
|
}
|
|
|
|
location /.well-known {
|
|
# Required by Authelia because "trust proxy" option is used.
|
|
# See https://expressjs.com/en/guide/behind-proxies.html
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
# Required by Authelia to build correct links for identity validation.
|
|
proxy_set_header X-Forwarded-Host $host$port_suffix;
|
|
proxy_set_header X-Forwarded-URI $request_uri;
|
|
|
|
# Needed for network ACLs to work. It appends the IP of the client to the list of IPs
|
|
# and allows Authelia to use it to match the network-based ACLs.
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_intercept_errors on;
|
|
|
|
proxy_pass $backend_endpoint;
|
|
}
|
|
|
|
location /locales {
|
|
# Required by Authelia because "trust proxy" option is used.
|
|
# See https://expressjs.com/en/guide/behind-proxies.html
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
# Required by Authelia to build correct links for identity validation.
|
|
proxy_set_header X-Forwarded-Host $host$port_suffix;
|
|
proxy_set_header X-Forwarded-URI $request_uri;
|
|
|
|
# Needed for network ACLs to work. It appends the IP of the client to the list of IPs
|
|
# and allows Authelia to use it to match the network-based ACLs.
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_intercept_errors on;
|
|
|
|
proxy_pass $backend_endpoint;
|
|
}
|
|
|
|
location /jwks.json {
|
|
# Required by Authelia because "trust proxy" option is used.
|
|
# See https://expressjs.com/en/guide/behind-proxies.html
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
# Required by Authelia to build correct links for identity validation.
|
|
proxy_set_header X-Forwarded-Host $host$port_suffix;
|
|
proxy_set_header X-Forwarded-URI $request_uri;
|
|
|
|
# Needed for network ACLs to work. It appends the IP of the client to the list of IPs
|
|
# and allows Authelia to use it to match the network-based ACLs.
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
proxy_intercept_errors on;
|
|
|
|
proxy_pass $backend_endpoint;
|
|
}
|
|
|
|
location /metrics {
|
|
proxy_pass $metrics_endpoint;
|
|
}
|
|
|
|
# Serves the portal application.
|
|
location / {
|
|
# Allow websockets for webpack to auto-reload.
|
|
proxy_http_version 1.1;
|
|
proxy_set_header Upgrade $http_upgrade;
|
|
proxy_set_header Connection "Upgrade";
|
|
proxy_set_header Host $host:$server_port;
|
|
|
|
add_header X-Content-Type-Options "nosniff";
|
|
add_header Referrer-Policy "strict-origin-when-cross-origin";
|
|
add_header X-Frame-Options "DENY";
|
|
add_header Permissions-Policy "accelerometer=(), autoplay=(), camera=(), display-capture=(), geolocation=(), gyroscope=(), keyboard-map=(), magnetometer=(), microphone=(), midi=(), payment=(), picture-in-picture=(), screen-wake-lock=(), sync-xhr=(), xr-spatial-tracking=(), interest-cohort=()";
|
|
add_header X-DNS-Prefetch-Control "off";
|
|
add_header Cross-Origin-Opener-Policy "same-origin";
|
|
add_header Cross-Origin-Embedder-Policy "require-corp";
|
|
add_header Cross-Origin-Resource-Policy "same-origin";
|
|
|
|
proxy_pass $frontend_endpoint;
|
|
}
|
|
|
|
# Proxies requests to backend for dev workflow.
|
|
location /devworkflow {
|
|
proxy_pass $backend_endpoint;
|
|
}
|
|
}
|
|
|
|
# Serves the home page.
|
|
server {
|
|
listen 8080 ssl;
|
|
server_name ~^home\.example([0-9])*\.com$;
|
|
|
|
resolver 127.0.0.11 ipv6=off;
|
|
set $upstream_endpoint http://nginx-backend;
|
|
|
|
ssl_certificate /pki/public.chain.pem;
|
|
ssl_certificate_key /pki/private.pem;
|
|
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
|
|
error_page 497 301 =307 https://$host:$server_port$request_uri;
|
|
|
|
location / {
|
|
proxy_set_header Host $http_host;
|
|
proxy_pass $upstream_endpoint;
|
|
}
|
|
}
|
|
|
|
# Example configuration of domains protected by Authelia.
|
|
server {
|
|
listen 8080 ssl;
|
|
server_name ~^(public|admin|secure|deny|dev|singlefactor|mx[1-2])(\.mail)?\.(?<basedomain>example([0-9])*\.com)$;
|
|
|
|
resolver 127.0.0.11 ipv6=off;
|
|
set $upstream_authelia https://authelia-backend:9091/api/authz/auth-request;
|
|
set $upstream_endpoint http://nginx-backend;
|
|
set $upstream_headers http://httpbin:8080/headers;
|
|
|
|
ssl_certificate /pki/public.chain.pem;
|
|
ssl_certificate_key /pki/private.pem;
|
|
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
add_header X-Content-Type-Options "nosniff";
|
|
add_header Referrer-Policy "strict-origin-when-cross-origin";
|
|
add_header X-Frame-Options "DENY";
|
|
add_header Permissions-Policy "accelerometer=(), autoplay=(), camera=(), display-capture=(), geolocation=(), gyroscope=(), keyboard-map=(), magnetometer=(), microphone=(), midi=(), payment=(), picture-in-picture=(), screen-wake-lock=(), sync-xhr=(), xr-spatial-tracking=(), interest-cohort=()";
|
|
add_header X-DNS-Prefetch-Control "off";
|
|
add_header Cross-Origin-Opener-Policy "same-origin";
|
|
add_header Cross-Origin-Embedder-Policy "require-corp";
|
|
add_header Cross-Origin-Resource-Policy "same-origin";
|
|
|
|
error_page 497 301 =307 https://$host:$server_port$request_uri;
|
|
|
|
# Reverse proxy to the backend. It is protected by Authelia by forwarding authorization checks
|
|
# to the virtual endpoint introduced by nginx and declared in the next block.
|
|
location / {
|
|
## Send a subrequest to Authelia to verify if the user is authenticated and has permission to access the resource.
|
|
auth_request /internal/authelia/authz;
|
|
|
|
## Save the upstream authorization response headers from Authelia to variables.
|
|
auth_request_set $authorization $upstream_http_authorization;
|
|
auth_request_set $proxy_authorization $upstream_http_proxy_authorization;
|
|
|
|
## Inject the authorization response headers from the variables into the request made to the backend.
|
|
proxy_set_header Authorization $authorization;
|
|
proxy_set_header Proxy-Authorization $proxy_authorization;
|
|
|
|
## Save the upstream metadata response headers from Authelia to variables.
|
|
auth_request_set $user $upstream_http_remote_user;
|
|
auth_request_set $groups $upstream_http_remote_groups;
|
|
auth_request_set $name $upstream_http_remote_name;
|
|
auth_request_set $email $upstream_http_remote_email;
|
|
|
|
## Inject the metadata response headers from the variables into the request made to the backend.
|
|
proxy_set_header Remote-User $user;
|
|
proxy_set_header Remote-Groups $groups;
|
|
proxy_set_header Remote-Email $email;
|
|
proxy_set_header Remote-Name $name;
|
|
|
|
## Include the Set-Cookie header if present.
|
|
auth_request_set $cookie $upstream_http_set_cookie;
|
|
add_header Set-Cookie $cookie;
|
|
|
|
## Configure the redirection when the Authz failure occurs. Lines starting with 'Modern Method' and 'Legacy Method'
|
|
## should be commented / uncommented as pairs. The modern method uses the session cookies configuration's authelia_url
|
|
## value to determine the redirection URL here. It's much simpler and compatible with the multi-cookie domain easily.
|
|
|
|
## Modern Method: Set the $redirection_url to the Location header of the response to the Authz endpoint.
|
|
auth_request_set $redirection_url $upstream_http_location;
|
|
|
|
## Modern Method: When there is a 401 response code from the Authz endpoint redirect to the $redirection_url.
|
|
error_page 401 =302 $redirection_url;
|
|
|
|
## Legacy Method: Set $target_url to the original requested URL.
|
|
## This requires http_set_misc module, replace 'set_escape_uri' with 'set' if you don't have this module.
|
|
# set $target_url $scheme://$http_host$request_uri;
|
|
|
|
## Legacy Method: When there is a 401 response code from the Authz endpoint redirect to the portal with the 'rd'
|
|
## URL parameter set to $target_url. This requires users update 'auth.example.com/' with their external authelia URL.
|
|
# error_page 401 =302 https://login.$basedomain:8080/?rd=$target_url;
|
|
|
|
# Authelia relies on Proxy-Authorization header to authenticate in basic auth.
|
|
# but for the sake of simplicity (because Authorization in supported in most
|
|
# clients) we take Authorization from the frontend and rewrite it to
|
|
# Proxy-Authorization before sending it to Authelia.
|
|
proxy_set_header Proxy-Authorization $http_authorization;
|
|
|
|
# Route the request to the correct virtual host in the backend.
|
|
proxy_set_header Host $http_host;
|
|
|
|
proxy_pass $upstream_endpoint;
|
|
}
|
|
|
|
# Virtual endpoint forwarding requests to Authelia server.
|
|
location /internal/authelia/authz {
|
|
## Essential Proxy Configuration
|
|
internal;
|
|
proxy_pass $upstream_authelia;
|
|
|
|
# Provide either X-Original-URL and X-Forwarded-Proto or
|
|
# X-Forwarded-Proto, X-Forwarded-Host and X-Forwarded-URI or both.
|
|
# Those headers will be used by Authelia to deduce the target url of the user.
|
|
#
|
|
# X-Forwarded-Proto is mandatory since Authelia uses the "trust proxy" option.
|
|
# See https://expressjs.com/en/guide/behind-proxies.html
|
|
proxy_set_header X-Original-Method $request_method;
|
|
proxy_set_header X-Original-URL $scheme://$host$port_suffix$request_uri;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header Content-Length "";
|
|
proxy_set_header Connection "";
|
|
|
|
# Authelia can receive Proxy-Authorization to authenticate however most of the clients
|
|
# support Authorization instead. Therefore we rewrite Authorization into Proxy-Authorization.
|
|
proxy_set_header Proxy-Authorization $http_authorization;
|
|
|
|
## Basic Proxy Configuration
|
|
proxy_pass_request_body off;
|
|
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503; # Timeout if the real server is dead
|
|
proxy_redirect http:// $scheme://;
|
|
proxy_http_version 1.1;
|
|
proxy_cache_bypass $cookie_session;
|
|
proxy_no_cache $cookie_session;
|
|
proxy_buffers 4 32k;
|
|
client_body_buffer_size 128k;
|
|
|
|
## Advanced Proxy Configuration
|
|
send_timeout 5m;
|
|
proxy_read_timeout 240;
|
|
proxy_send_timeout 240;
|
|
proxy_connect_timeout 240;
|
|
}
|
|
|
|
# Used by suites to test the forwarded users and groups headers produced by Authelia.
|
|
location /headers {
|
|
## Send a subrequest to Authelia to verify if the user is authenticated and has permission to access the resource.
|
|
auth_request /internal/authelia/authz;
|
|
|
|
## Save the upstream authorization response headers from Authelia to variables.
|
|
auth_request_set $authorization $upstream_http_authorization;
|
|
auth_request_set $proxy_authorization $upstream_http_proxy_authorization;
|
|
|
|
## Inject the authorization response headers from the variables into the request made to the backend.
|
|
proxy_set_header Authorization $authorization;
|
|
proxy_set_header Proxy-Authorization $proxy_authorization;
|
|
|
|
## Save the upstream metadata response headers from Authelia to variables.
|
|
auth_request_set $user $upstream_http_remote_user;
|
|
auth_request_set $groups $upstream_http_remote_groups;
|
|
auth_request_set $name $upstream_http_remote_name;
|
|
auth_request_set $email $upstream_http_remote_email;
|
|
|
|
## Inject the metadata response headers from the variables into the request made to the backend.
|
|
proxy_set_header Remote-User $user;
|
|
proxy_set_header Remote-Groups $groups;
|
|
proxy_set_header Remote-Email $email;
|
|
proxy_set_header Remote-Name $name;
|
|
|
|
## Include the Set-Cookie header if present.
|
|
auth_request_set $cookie $upstream_http_set_cookie;
|
|
add_header Set-Cookie $cookie;
|
|
|
|
## Configure the redirection when the Authz failure occurs. Lines starting with 'Modern Method' and 'Legacy Method'
|
|
## should be commented / uncommented as pairs. The modern method uses the session cookies configuration's authelia_url
|
|
## value to determine the redirection URL here. It's much simpler and compatible with the multi-cookie domain easily.
|
|
|
|
## Modern Method: Set the $redirection_url to the Location header of the response to the Authz endpoint.
|
|
auth_request_set $redirection_url $upstream_http_location;
|
|
|
|
## Modern Method: When there is a 401 response code from the Authz endpoint redirect to the $redirection_url.
|
|
error_page 401 =302 $redirection_url;
|
|
|
|
## Legacy Method: Set $target_url to the original requested URL.
|
|
## This requires http_set_misc module, replace 'set_escape_uri' with 'set' if you don't have this module.
|
|
# set $target_url $scheme://$http_host$request_uri;
|
|
|
|
## Legacy Method: When there is a 401 response code from the Authz endpoint redirect to the portal with the 'rd'
|
|
## URL parameter set to $target_url. This requires users update 'auth.example.com/' with their external authelia URL.
|
|
# error_page 401 =302 https://login.$basedomain:8080/?rd=$target_url;
|
|
|
|
proxy_pass $upstream_headers;
|
|
}
|
|
}
|
|
|
|
# Example configuration of domains protected by Authelia.
|
|
server {
|
|
listen 8080 ssl;
|
|
server_name ~^oidc(-public)?\.(?<basedomain>example([0-9])*\.com)$;
|
|
|
|
resolver 127.0.0.11 ipv6=off;
|
|
set $upstream_authelia https://authelia-backend:9091/api/authz/auth-request;
|
|
set $upstream_endpoint http://oidc-client:8080;
|
|
|
|
ssl_certificate /pki/public.chain.pem;
|
|
ssl_certificate_key /pki/private.pem;
|
|
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
add_header X-Content-Type-Options "nosniff";
|
|
add_header Referrer-Policy "strict-origin-when-cross-origin";
|
|
add_header X-Frame-Options "DENY";
|
|
add_header Permissions-Policy "accelerometer=(), autoplay=(), camera=(), display-capture=(), geolocation=(), gyroscope=(), keyboard-map=(), magnetometer=(), microphone=(), midi=(), payment=(), picture-in-picture=(), screen-wake-lock=(), sync-xhr=(), xr-spatial-tracking=(), interest-cohort=()";
|
|
add_header X-DNS-Prefetch-Control "off";
|
|
add_header Cross-Origin-Opener-Policy "same-origin";
|
|
add_header Cross-Origin-Embedder-Policy "require-corp";
|
|
add_header Cross-Origin-Resource-Policy "same-origin";
|
|
|
|
error_page 497 301 =307 https://$host:$server_port$request_uri;
|
|
|
|
# Reverse proxy to the backend. It is protected by Authelia by forwarding authorization checks
|
|
# to the virtual endpoint introduced by nginx and declared in the next block.
|
|
location / {
|
|
## Send a subrequest to Authelia to verify if the user is authenticated and has permission to access the resource.
|
|
auth_request /internal/authelia/authz;
|
|
|
|
## Save the upstream authorization response headers from Authelia to variables.
|
|
auth_request_set $authorization $upstream_http_authorization;
|
|
auth_request_set $proxy_authorization $upstream_http_proxy_authorization;
|
|
|
|
## Inject the authorization response headers from the variables into the request made to the backend.
|
|
proxy_set_header Authorization $authorization;
|
|
proxy_set_header Proxy-Authorization $proxy_authorization;
|
|
|
|
## Save the upstream metadata response headers from Authelia to variables.
|
|
auth_request_set $user $upstream_http_remote_user;
|
|
auth_request_set $groups $upstream_http_remote_groups;
|
|
auth_request_set $name $upstream_http_remote_name;
|
|
auth_request_set $email $upstream_http_remote_email;
|
|
|
|
## Inject the metadata response headers from the variables into the request made to the backend.
|
|
proxy_set_header Remote-User $user;
|
|
proxy_set_header Remote-Groups $groups;
|
|
proxy_set_header Remote-Email $email;
|
|
proxy_set_header Remote-Name $name;
|
|
|
|
## Include the Set-Cookie header if present.
|
|
auth_request_set $cookie $upstream_http_set_cookie;
|
|
add_header Set-Cookie $cookie;
|
|
|
|
## Configure the redirection when the Authz failure occurs. Lines starting with 'Modern Method' and 'Legacy Method'
|
|
## should be commented / uncommented as pairs. The modern method uses the session cookies configuration's authelia_url
|
|
## value to determine the redirection URL here. It's much simpler and compatible with the multi-cookie domain easily.
|
|
|
|
## Modern Method: Set the $redirection_url to the Location header of the response to the Authz endpoint.
|
|
auth_request_set $redirection_url $upstream_http_location;
|
|
|
|
## Modern Method: When there is a 401 response code from the Authz endpoint redirect to the $redirection_url.
|
|
error_page 401 =302 $redirection_url;
|
|
|
|
## Legacy Method: Set $target_url to the original requested URL.
|
|
## This requires http_set_misc module, replace 'set_escape_uri' with 'set' if you don't have this module.
|
|
# set $target_url $scheme://$http_host$request_uri;
|
|
|
|
## Legacy Method: When there is a 401 response code from the Authz endpoint redirect to the portal with the 'rd'
|
|
## URL parameter set to $target_url. This requires users update 'auth.example.com/' with their external authelia URL.
|
|
# error_page 401 =302 https://login.$basedomain:8080/?rd=$target_url;
|
|
|
|
# Route the request to the correct virtual host in the backend.
|
|
proxy_set_header Host $http_host;
|
|
|
|
proxy_pass $upstream_endpoint;
|
|
}
|
|
|
|
# Virtual endpoint forwarding requests to Authelia server.
|
|
location /internal/authelia/authz {
|
|
## Essential Proxy Configuration
|
|
internal;
|
|
proxy_pass $upstream_authelia;
|
|
|
|
# Provide either X-Original-URL and X-Forwarded-Proto or
|
|
# X-Forwarded-Proto, X-Forwarded-Host and X-Forwarded-URI or both.
|
|
# Those headers will be used by Authelia to deduce the target url of the user.
|
|
#
|
|
# X-Forwarded-Proto is mandatory since Authelia uses the "trust proxy" option.
|
|
proxy_set_header X-Original-Method $request_method;
|
|
proxy_set_header X-Original-URL $scheme://$host$port_suffix$request_uri;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header Content-Length "";
|
|
proxy_set_header Connection "";
|
|
|
|
# Authelia can receive Proxy-Authorization to authenticate however most of the clients
|
|
# support Authorization instead. Therefore we rewrite Authorization into Proxy-Authorization.
|
|
proxy_set_header Proxy-Authorization $http_authorization;
|
|
|
|
## Basic Proxy Configuration
|
|
proxy_pass_request_body off;
|
|
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503; # Timeout if the real server is dead
|
|
proxy_redirect http:// $scheme://;
|
|
proxy_http_version 1.1;
|
|
proxy_cache_bypass $cookie_session;
|
|
proxy_no_cache $cookie_session;
|
|
proxy_buffers 4 32k;
|
|
client_body_buffer_size 128k;
|
|
|
|
## Advanced Proxy Configuration
|
|
send_timeout 5m;
|
|
proxy_read_timeout 240;
|
|
proxy_send_timeout 240;
|
|
proxy_connect_timeout 240;
|
|
}
|
|
}
|
|
|
|
# OpenID Connect 1.0 conformance suite. This replaces the nginx image the conformance project publishes, whose
|
|
# configuration is baked in and only answers on that container's own address. The three listeners below mirror
|
|
# that image: 8443 is the ordinary one, 8444 asks for a client certificate so the mutual TLS tests have somewhere
|
|
# to land, and 8445 narrows the ciphers to the FAPI 2.0 set. Only 8443 is exercised today, but a suite that grows
|
|
# a profile reaching for the other two finds them where it expects rather than failing part way through a plan.
|
|
#
|
|
# Each listener repeats the proxy body rather than sharing one: nginx would need an include file mounted beside
|
|
# this one to factor it out, and the ports differ in the handshake, not in what they forward. The buffer sizes,
|
|
# timeouts and forwarded headers are what the published image sets and the suite depends on, so they are
|
|
# reproduced here rather than left to the defaults the blocks above share.
|
|
server {
|
|
listen 8443 ssl;
|
|
server_name ~^conformance\.example([0-9])*\.com$;
|
|
|
|
# The mutual TLS tests have to arrive on a listener that asks for a client certificate, which this one does
|
|
# not, so the suite is told it reached the wrong host and reports that rather than timing out.
|
|
ssl_verify_client off;
|
|
|
|
resolver 127.0.0.11 ipv6=off;
|
|
set $upstream_endpoint http://conformance-server:8080;
|
|
|
|
ssl_certificate /pki/public.chain.pem;
|
|
ssl_certificate_key /pki/private.pem;
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
|
|
# The suite sends request objects and authorization requests that overflow the default 1k header buffer.
|
|
client_header_buffer_size 32k;
|
|
large_client_header_buffers 4 32k;
|
|
|
|
location / {
|
|
# The suite has requests that block waiting for callbacks for up to 60s, which the default 60s proxy
|
|
# timeout races against and turns into sporadic 504s.
|
|
proxy_read_timeout 120s;
|
|
proxy_send_timeout 120s;
|
|
|
|
set $mtls_wrong_host "";
|
|
if ($request_uri ~* "^/test-mtls") {
|
|
set $mtls_wrong_host "true";
|
|
}
|
|
proxy_set_header X-Test-Mtls-Called-On-Wrong-Host $mtls_wrong_host;
|
|
|
|
# Host is deliberately $host rather than $http_host: the suite rebuilds its own base URL from
|
|
# X-Forwarded-Host and X-Forwarded-Port, so a port carried in either of the first two would be doubled.
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
proxy_set_header X-Forwarded-Port $server_port;
|
|
proxy_set_header X-Forwarded-Uri $request_uri;
|
|
proxy_set_header X-Ssl-Cipher $ssl_cipher;
|
|
proxy_set_header X-Ssl-Protocol $ssl_protocol;
|
|
proxy_set_header X-Ssl-Cert $ssl_client_cert;
|
|
proxy_set_header Forwarded "by=$server_addr;for=$remote_addr;host=$host;proto=$scheme";
|
|
|
|
proxy_pass_request_headers on;
|
|
proxy_pass $upstream_endpoint;
|
|
}
|
|
}
|
|
|
|
# Mutual TLS. The client certificate is requested but not checked against a CA: the suite inspects it itself out
|
|
# of X-Ssl-Cert, which is why this is optional_no_ca rather than on.
|
|
server {
|
|
listen 8444 ssl;
|
|
server_name ~^conformance\.example([0-9])*\.com$;
|
|
|
|
ssl_verify_client optional_no_ca;
|
|
|
|
resolver 127.0.0.11 ipv6=off;
|
|
set $upstream_endpoint http://conformance-server:8080;
|
|
|
|
ssl_certificate /pki/public.chain.pem;
|
|
ssl_certificate_key /pki/private.pem;
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
|
|
client_header_buffer_size 32k;
|
|
large_client_header_buffers 4 32k;
|
|
|
|
location / {
|
|
proxy_read_timeout 120s;
|
|
proxy_send_timeout 120s;
|
|
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
proxy_set_header X-Forwarded-Port $server_port;
|
|
proxy_set_header X-Forwarded-Uri $request_uri;
|
|
proxy_set_header X-Ssl-Cipher $ssl_cipher;
|
|
proxy_set_header X-Ssl-Protocol $ssl_protocol;
|
|
proxy_set_header X-Ssl-Cert $ssl_client_cert;
|
|
proxy_set_header Forwarded "by=$server_addr;for=$remote_addr;host=$host;proto=$scheme";
|
|
|
|
proxy_pass_request_headers on;
|
|
proxy_pass $upstream_endpoint;
|
|
}
|
|
}
|
|
|
|
# The FAPI 2.0 Final security profile cipher set.
|
|
server {
|
|
listen 8445 ssl;
|
|
server_name ~^conformance\.example([0-9])*\.com$;
|
|
|
|
ssl_verify_client optional_no_ca;
|
|
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384;
|
|
ssl_prefer_server_ciphers on;
|
|
|
|
resolver 127.0.0.11 ipv6=off;
|
|
set $upstream_endpoint http://conformance-server:8080;
|
|
|
|
ssl_certificate /pki/public.chain.pem;
|
|
ssl_certificate_key /pki/private.pem;
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
|
|
client_header_buffer_size 32k;
|
|
large_client_header_buffers 4 32k;
|
|
|
|
location / {
|
|
proxy_read_timeout 120s;
|
|
proxy_send_timeout 120s;
|
|
|
|
proxy_set_header Host $host;
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header X-Forwarded-Host $host;
|
|
proxy_set_header X-Forwarded-Port $server_port;
|
|
proxy_set_header X-Forwarded-Uri $request_uri;
|
|
proxy_set_header X-Ssl-Cipher $ssl_cipher;
|
|
proxy_set_header X-Ssl-Protocol $ssl_protocol;
|
|
proxy_set_header X-Ssl-Cert $ssl_client_cert;
|
|
proxy_set_header Forwarded "by=$server_addr;for=$remote_addr;host=$host;proto=$scheme";
|
|
|
|
proxy_pass_request_headers on;
|
|
proxy_pass $upstream_endpoint;
|
|
}
|
|
}
|
|
|
|
# Fake Web Mail used to receive emails sent by Authelia.
|
|
server {
|
|
listen 8080 ssl;
|
|
server_name ~^mail\.example([0-9])*\.com$;
|
|
|
|
resolver 127.0.0.11 ipv6=off;
|
|
set $upstream_endpoint http://smtp:8025;
|
|
|
|
ssl_certificate /pki/public.chain.pem;
|
|
ssl_certificate_key /pki/private.pem;
|
|
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
|
|
error_page 497 301 =307 https://$host:$server_port$request_uri;
|
|
|
|
location / {
|
|
proxy_set_header Host $http_host;
|
|
proxy_pass $upstream_endpoint;
|
|
}
|
|
}
|
|
|
|
# Fake API emulating Duo behavior
|
|
server {
|
|
listen 443 ssl;
|
|
server_name ~^duo\.example([0-9])*\.com$;
|
|
|
|
resolver 127.0.0.11 ipv6=off;
|
|
set $upstream_endpoint http://duo-api:3000;
|
|
|
|
ssl_certificate /pki/public.chain.pem;
|
|
ssl_certificate_key /pki/private.pem;
|
|
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
|
|
error_page 497 301 =307 https://$host:$server_port$request_uri;
|
|
|
|
location / {
|
|
proxy_set_header Host $http_host;
|
|
proxy_pass $upstream_endpoint;
|
|
}
|
|
}
|
|
|
|
# Matches all domains. It redirects to the home page.
|
|
server {
|
|
listen 8080 ssl;
|
|
server_name _;
|
|
|
|
ssl_certificate /pki/public.chain.pem;
|
|
ssl_certificate_key /pki/private.pem;
|
|
|
|
return 301 https://home.example.com:8080/;
|
|
}
|
|
}
|