Created
March 31, 2025 11:44
-
-
Save joseEkcit/079a26489093337ba2a65431e92919d4 to your computer and use it in GitHub Desktop.
Example nginx configuration for FusionAuth SSO bootstrap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
upstream auth { | |
server 0.0.0.0:9011; | |
keepalive 8; | |
} | |
server { | |
server_name auth.mydomain.tld; | |
access_log /var/log/nginx/auth-access.log; | |
# Other previous server configuration... | |
location /oauth2/authorize { | |
# Add the Authorization header only if the cookie is present | |
# Initialize variables | |
set $auth_token ""; | |
set $auth_header ""; | |
# Extract the cookie value from the Cookie header | |
if ($http_cookie ~* "myfusionssoauthtoken=([^;]+)") { | |
set $auth_token $1; | |
} | |
# Only set Authorization header if the token is not empty | |
if ($auth_token != "") { | |
set $auth_header "Bearer $auth_token"; | |
} | |
proxy_set_header Authorization $auth_header; | |
proxy_pass http://auth; | |
proxy_set_header X-Robots-Tag "noindex, nofollow"; | |
proxy_set_header Host $http_host; | |
proxy_set_header X-Forwarded-Port "443"; | |
proxy_set_header X-Forwarded-Proto "https"; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
} | |
# Rest of the server configuration... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This file shows an example on how to set up the /oauth2/authorize location in nginx to pass the value of a cookie called "myfusionssoauthtoken" as a request header to be consumed in the SSO session bootstrap flow. It's not a full nginx configuration file for FusionAuth, refer to FusionAuth docs for an example of that.