# If you want to forward http request to https enable the
# following virtual server.
#server {
#        listen  80;
#        server_name     $hostname;
#        return 301 https://$hostname$request_uri;
#}

server {
        listen 443 ssl;
        server_name     $hostname;
        ssl_certificate /etc/ssl/certs/edumfa-bundle.crt;
        ssl_certificate_key /etc/ssl/private/edumfa.key;
	ssl_prefer_server_ciphers On;
	ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
	ssl_ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS;

        access_log      /var/log/edumfa/access.log;
        error_log       /var/log/edumfa/error.log info;

        location / {
                uwsgi_pass      unix:/run/uwsgi/app/edumfa/edumfa.socket;
                include         uwsgi_params;
                uwsgi_param     UWSGI_SCHEME $scheme;
                uwsgi_param     SERVER_SOFTWARE nginx/$nginx_version;
                uwsgi_param SCRIPT_NAME '';
                # Never forward client-supplied request headers to eduMFA.
                # In particular the "Remote-User" header should not reach eduMFA
                # to prevent webui.remote_user misconfigurations, see issue
                # tracker "implement trusted_proxy feature for remote_user".
                uwsgi_pass_request_headers off;
                # Explicitly re-add the request headers that eduMFA needs:
                uwsgi_param HTTP_AUTHORIZATION $http_authorization;
                uwsgi_param HTTP_HOST $http_host;
                uwsgi_param HTTP_USER_AGENT $http_user_agent;
                uwsgi_param HTTP_ACCEPT $http_accept;
                uwsgi_param HTTP_ACCEPT_LANGUAGE $http_accept_language;
                uwsgi_param HTTP_ORIGIN $http_origin;
                uwsgi_param HTTP_X_FORWARDED_FOR $http_x_forwarded_for;
                # If you use policy conditions on custom HTTP request headers
                # ("HTTP Request header" section), re-add them here as well, e.g.:
                # uwsgi_param HTTP_X_CUSTOM_HEADER $http_x_custom_header;
        }

        # Yubico servers use /wsapi/2.0/verify as the path in the
        # validation URL. Some tools (e.g. Kolab 2fa) let the 
        # user/admin change the api host, but not the rest of
        # the URL. Uncomment the following two lines to reroute 
        # the api URL internally to eduMFAs /ttype/yubikey.
        #rewrite ^/wsapi/2.0/verify(.*)  /ttype/yubikey$1 last;

}

