eole-lemonldap/tmpl/portal-nginx.conf

89 lines
2.5 KiB
Plaintext
Raw Normal View History

## map directive must be in http context
# Uncomment this if you use Auth SSL:
#map $ssl_client_s_dn $ssl_client_s_dn_cn {
# default "";
# ~/CN=(?<CN>[^/]+) $CN;
#}
%set %%webDomain = %%authWebName.split('.',1)[1]
%set %%CSPTargets = %%custom_join(['http://*.{0} https://*.{0}'.format(d) for d in set([%%webDomain] + %%getVar('llCSPTargets'))], ' ')
2018-03-02 15:44:00 +01:00
server {
listen 80;
server_name %%authWebName;
return 301 https://$host$request_uri;
}
2018-03-02 15:44:00 +01:00
server {
listen 443;
ssl on;
%if %%cert_type == "letsencrypt"
ssl_certificate %%le_config_dir/live/%%authWebName/cert.pem;
ssl_certificate_key %%le_config_dir/live/%%authWebName/privkey.pem;
%else
ssl_certificate %%server_cert;
ssl_certificate_key %%server_key;
%end if
ssl_client_certificate /etc/ssl/certs/ca..crt;
access_log /var/log/nginx/auth-lemon-ldap.access-ssl.log;
server_name %%authWebName;
root /usr/share/lemonldap-ng/portal/htdocs/;
if ($uri !~ ^/((static|javascript|favicon).*|.*\.psgi)) {
rewrite ^/(.*)$ /index.psgi/$1 break;
}
location ~ ^(?<sc>/.*\.psgi)(?:$|/) {
# Note that Content-Security-Policy header is generated by portal itself
2018-03-02 15:44:00 +01:00
# FastCGI configuration
2018-03-02 15:44:00 +01:00
include /etc/nginx/fastcgi_params;
fastcgi_pass unix:/var/run/llng-fastcgi-server/llng-fastcgi.sock;
fastcgi_param LLTYPE psgi;
2018-03-02 15:44:00 +01:00
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_split_path_info ^(.*\.psgi)(/.*)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_hide_header Content-Security-Policy;
add_header Content-Security-Policy "default-src 'self'; form-action 'self' %%CSPTargets; object-src 'none'";
2018-03-02 15:44:00 +01:00
}
index index.psgi;
2018-03-02 15:44:00 +01:00
location / {
try_files $uri $uri/ =404;
# Uncomment this if you use https only
#add_header Strict-Transport-Security "max-age=15768000";
2018-03-02 15:44:00 +01:00
}
location /static/ {
alias /usr/share/lemonldap-ng/portal/htdocs/static/;
2018-03-02 15:44:00 +01:00
}
# REST/SOAP functions for sessions management (disabled by default)
location /index.psgi/adminSessions {
2018-03-02 15:44:00 +01:00
deny all;
}
# REST/SOAP functions for sessions access (disabled by default)
location /index.psgi/sessions {
2018-03-02 15:44:00 +01:00
deny all;
}
# REST/SOAP functions for configuration access (disabled by default)
location /index.psgi/config {
2018-03-02 15:44:00 +01:00
deny all;
}
# REST/SOAP functions for notification insertion (disabled by default)
location /index.psgi/notification {
deny all;
}
2018-03-02 15:44:00 +01:00
# DEBIAN
# If install was made with USEDEBIANLIBS (official releases), uncomment this
#location /javascript/ {
# alias /usr/share/javascript/;
#}
}