--- ############################################################### # Authelia configuration # ############################################################### #基本配置:配置端口、jwt秘钥、默认的跳转地址、totp对应的域名 host: 0.0.0.0 port: 9091 log_level: debug # This secret can also be set using the env variables AUTHELIA_JWT_SECRET_FILE jwt_secret: adakusdhhadsk default_redirection_url: https://www.abcd.com totp: issuer: abcd.com
# duo_api: # hostname: api-123456789.example.com # integration_key: ABCDEF # # This secret can also be set using the env variables AUTHELIA_DUO_API_SECRET_KEY_FILE # secret_key: 1234567890abcdefghifjkl
#seesion 配置 session: name: authelia # This secret can also be set using the env variables AUTHELIA_SESSION_SECRET_FILE secret: asdasfjjhas expiration: 3600 # 1 hour inactivity: 300 # 5 minutes domain: abcd.com # Should match whatever your root protected domain is
regulation: max_retries: 3 find_time: 120 ban_time: 300 #存储配置 storage: mysql: host: mysql.abcd.com port: 3306 database: authelia username: authelia ## Password can also be set using a secret: https://www.authelia.com/docs/configuration/secrets.html password: 123456 #邮件发件配置,主要用于修改密码等操作 notifier: smtp: username: noreply@abcd.com # This secret can also be set using the env variables AUTHELIA_NOTIFIER_SMTP_PASSWORD_FILE password: abcdaklfdj host: smtp.exmail.qq.com port: 465 sender: noreply@abcd.com ...
set$upstream_authelia http://127.0.0.1:9999/api/verify; # Virtual endpoint created by nginx to forward auth requests. location /authelia { internal; proxy_pass_request_body off; proxy_pass $upstream_authelia; proxy_set_header Content-Length "";
# Timeout if the real server is dead proxy_next_upstream error timeout invalid_header http_500 http_502 http_503;
# [REQUIRED] Needed by Authelia to check authorizations of the resource. # 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. # Basic Proxy Config client_body_buffer_size 128k; proxy_set_header Host $host; proxy_set_header X-Original-URL $scheme://$http_host$request_uri; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-Method $request_method; proxy_set_header X-Forwarded-Proto $scheme; proxy_set_header X-Forwarded-Host $http_host; proxy_set_header X-Forwarded-Uri $request_uri; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header X-Forwarded-Ssl on; proxy_redirect http:// $scheme://; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_cache_bypass $cookie_session; proxy_no_cache $cookie_session; proxy_buffers 4 32k;
# Basic Authelia Config # Send a subsequent request to Authelia to verify if the user is authenticated # and has the right permissions to access the resource. auth_request /authelia; # Set the `target_url` variable based on the request. It will be used to build the portal # URL with the correct redirection parameter. auth_request_set $target_url$scheme://$http_host$request_uri; # Set the X-Forwarded-User and X-Forwarded-Groups with the headers # returned by Authelia for the backends which can consume them. # This is not safe, as the backend must make sure that they come from the # proxy. In the future, it's gonna be safe to just use OAuth. 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; proxy_set_header Remote-User $user; proxy_set_header Remote-Groups $groups; proxy_set_header Remote-Name $name; proxy_set_header Remote-Email $email; # If Authelia returns 401, then nginx redirects the user to the login portal. # If it returns 200, then the request pass through to the backend. # For other type of errors, nginx will handle them as usual. error_page 401 =302 https://auth.songbo.fun/?rd=$target_url;
如果出现如下警告: nginx: [warn] could not build optimal proxy_headers_hash, you should increase either proxy_headers_hash_max_size: 512 or proxy_headers_hash_bucket_size: 64; ignoring proxy_headers_hash_bucket_size 在nginx.conf 配置文件中加上 以下配置即可。