289 lines
9.1 KiB
Nginx Configuration File
289 lines
9.1 KiB
Nginx Configuration File
# nginx-sso - example nginx config
|
|
#
|
|
# (c) 2015 by Johannes Gilger <heipei@hackvalue.de>
|
|
#
|
|
# This is an example config for using nginx with the nginx-sso cookie system.
|
|
# For simplicity, this config sets up two fictional vhosts that you can use to
|
|
# test against both components of the nginx-sso system: ssoauth & ssologin.
|
|
# In a real deployment, these vhosts would be separate hosts.
|
|
|
|
#user nobody;
|
|
worker_processes 1;
|
|
|
|
#error_log logs/error.log;
|
|
#error_log logs/error.log notice;
|
|
#error_log logs/error.log info;
|
|
|
|
#pid logs/nginx.pid;
|
|
|
|
events {
|
|
worker_connections 1024;
|
|
}
|
|
|
|
|
|
http {
|
|
server {
|
|
listen 443 ssl;
|
|
server_name home.test.local;
|
|
|
|
ssl on;
|
|
ssl_certificate /etc/ssl/server.crt;
|
|
ssl_certificate_key /etc/ssl/server.key;
|
|
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
add_header X-Frame-Options "SAMEORIGIN";
|
|
|
|
location / {
|
|
proxy_set_header Host $http_host;
|
|
|
|
proxy_pass http://nginx-backend/;
|
|
}
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl;
|
|
server_name public.test.local;
|
|
|
|
ssl on;
|
|
ssl_certificate /etc/ssl/server.crt;
|
|
ssl_certificate_key /etc/ssl/server.key;
|
|
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
add_header X-Frame-Options "SAMEORIGIN";
|
|
|
|
location /auth_verify {
|
|
internal;
|
|
proxy_set_header X-Original-URI $request_uri;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header Host $http_host;
|
|
proxy_set_header Content-Length "";
|
|
|
|
proxy_pass http://nginx-authelia/api/verify;
|
|
}
|
|
|
|
location / {
|
|
auth_request /auth_verify;
|
|
|
|
auth_request_set $redirect $upstream_http_redirect;
|
|
|
|
auth_request_set $user $upstream_http_remote_user;
|
|
proxy_set_header X-Forwarded-User $user;
|
|
|
|
auth_request_set $groups $upstream_http_remote_groups;
|
|
proxy_set_header Remote-Groups $groups;
|
|
|
|
proxy_set_header Host $http_host;
|
|
|
|
error_page 401 =302 https://auth.test.local:8080?redirect=$redirect;
|
|
error_page 403 = https://auth.test.local:8080/error/403;
|
|
|
|
proxy_pass http://nginx-backend/;
|
|
}
|
|
|
|
location /headers {
|
|
auth_request /auth_verify;
|
|
|
|
auth_request_set $redirect $upstream_http_redirect;
|
|
|
|
auth_request_set $user $upstream_http_remote_user;
|
|
proxy_set_header Custom-Forwarded-User $user;
|
|
|
|
auth_request_set $groups $upstream_http_remote_groups;
|
|
proxy_set_header Custom-Forwarded-Groups $groups;
|
|
|
|
error_page 401 =302 https://auth.test.local:8080?redirect=$redirect;
|
|
error_page 403 = https://auth.test.local:8080/error/403;
|
|
|
|
proxy_pass http://httpbin:8000/headers;
|
|
}
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl;
|
|
server_name admin.test.local;
|
|
|
|
ssl on;
|
|
ssl_certificate /etc/ssl/server.crt;
|
|
ssl_certificate_key /etc/ssl/server.key;
|
|
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
add_header X-Frame-Options "SAMEORIGIN";
|
|
|
|
location /auth_verify {
|
|
internal;
|
|
proxy_set_header X-Original-URI $request_uri;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header Host $http_host;
|
|
proxy_set_header Content-Length "";
|
|
|
|
proxy_pass http://nginx-authelia/api/verify;
|
|
}
|
|
|
|
location / {
|
|
auth_request /auth_verify;
|
|
|
|
auth_request_set $redirect $upstream_http_redirect;
|
|
|
|
auth_request_set $user $upstream_http_remote_user;
|
|
proxy_set_header X-Forwarded-User $user;
|
|
|
|
auth_request_set $groups $upstream_http_remote_groups;
|
|
proxy_set_header Remote-Groups $groups;
|
|
|
|
proxy_set_header Host $http_host;
|
|
|
|
error_page 401 =302 https://auth.test.local:8080?redirect=$redirect;
|
|
error_page 403 = https://auth.test.local:8080/error/403;
|
|
|
|
proxy_pass http://nginx-backend/;
|
|
}
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl;
|
|
server_name dev.test.local;
|
|
|
|
ssl on;
|
|
ssl_certificate /etc/ssl/server.crt;
|
|
ssl_certificate_key /etc/ssl/server.key;
|
|
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
add_header X-Frame-Options "SAMEORIGIN";
|
|
|
|
location /auth_verify {
|
|
internal;
|
|
proxy_set_header X-Original-URI $request_uri;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header Host $http_host;
|
|
proxy_set_header Content-Length "";
|
|
|
|
proxy_pass http://nginx-authelia/api/verify;
|
|
}
|
|
|
|
location / {
|
|
auth_request /auth_verify;
|
|
|
|
auth_request_set $redirect $upstream_http_redirect;
|
|
|
|
auth_request_set $user $upstream_http_remote_user;
|
|
proxy_set_header X-Forwarded-User $user;
|
|
|
|
auth_request_set $groups $upstream_http_remote_groups;
|
|
proxy_set_header Remote-Groups $groups;
|
|
|
|
proxy_set_header Host $http_host;
|
|
|
|
error_page 401 =302 https://auth.test.local:8080?redirect=$redirect;
|
|
error_page 403 = https://auth.test.local:8080/error/403;
|
|
|
|
proxy_pass http://nginx-backend/;
|
|
}
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl;
|
|
server_name mx1.mail.test.local mx2.mail.test.local;
|
|
|
|
ssl on;
|
|
ssl_certificate /etc/ssl/server.crt;
|
|
ssl_certificate_key /etc/ssl/server.key;
|
|
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
add_header X-Frame-Options "SAMEORIGIN";
|
|
|
|
location /auth_verify {
|
|
internal;
|
|
proxy_set_header X-Original-URI $request_uri;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header Host $http_host;
|
|
proxy_set_header Content-Length "";
|
|
|
|
proxy_pass http://nginx-authelia/api/verify;
|
|
}
|
|
|
|
location / {
|
|
auth_request /auth_verify;
|
|
|
|
auth_request_set $redirect $upstream_http_redirect;
|
|
|
|
auth_request_set $user $upstream_http_remote_user;
|
|
proxy_set_header X-Forwarded-User $user;
|
|
|
|
auth_request_set $groups $upstream_http_remote_groups;
|
|
proxy_set_header Remote-Groups $groups;
|
|
|
|
proxy_set_header Host $http_host;
|
|
|
|
error_page 401 =302 https://auth.test.local:8080?redirect=$redirect;
|
|
error_page 403 = https://auth.test.local:8080/error/403;
|
|
|
|
proxy_pass http://nginx-backend/;
|
|
}
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl;
|
|
server_name single_factor.test.local;
|
|
|
|
ssl on;
|
|
ssl_certificate /etc/ssl/server.crt;
|
|
ssl_certificate_key /etc/ssl/server.key;
|
|
|
|
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
|
add_header X-Frame-Options "SAMEORIGIN";
|
|
|
|
location /auth_verify {
|
|
internal;
|
|
proxy_set_header X-Original-URI $request_uri;
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
proxy_set_header Host $http_host;
|
|
proxy_set_header Content-Length "";
|
|
proxy_set_header Proxy-Authorization $http_authorization;
|
|
|
|
proxy_pass http://nginx-authelia/api/verify;
|
|
}
|
|
|
|
location / {
|
|
auth_request /auth_verify;
|
|
|
|
auth_request_set $redirect $upstream_http_redirect;
|
|
|
|
auth_request_set $user $upstream_http_remote_user;
|
|
proxy_set_header X-Forwarded-User $user;
|
|
|
|
auth_request_set $groups $upstream_http_remote_groups;
|
|
proxy_set_header Remote-Groups $groups;
|
|
|
|
proxy_set_header Host $http_host;
|
|
|
|
error_page 401 =302 https://auth.test.local:8080?redirect=$redirect;
|
|
error_page 403 = https://auth.test.local:8080/error/403;
|
|
|
|
proxy_pass http://nginx-backend/;
|
|
}
|
|
|
|
location /headers {
|
|
auth_request /auth_verify;
|
|
|
|
auth_request_set $redirect $upstream_http_redirect;
|
|
|
|
auth_request_set $user $upstream_http_remote_user;
|
|
proxy_set_header Custom-Forwarded-User $user;
|
|
|
|
auth_request_set $groups $upstream_http_remote_groups;
|
|
proxy_set_header Custom-Forwarded-Groups $groups;
|
|
|
|
proxy_pass http://httpbin:8000/headers;
|
|
|
|
error_page 401 =302 https://auth.test.local:8080?redirect=$redirect;
|
|
error_page 403 = https://auth.test.local:8080/error/403;
|
|
}
|
|
}
|
|
}
|
|
|