log_format seafileformat '$http_x_forwarded_for $remote_addr [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" $upstream_response_time';

server {
    if ($host = seafile.crenam.space) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


	listen 80;
	server_name seafile.crenam.space;
	location / {
		return 301 https://$server_name$request_uri;
	}


}

server {
	listen 443 ssl http2;
	server_name seafile.crenam.space;
	
	include /etc/nginx/snippets/authelia-location.conf;

	location / {
		include /etc/nginx/snippets/proxy.conf;
		include /etc/nginx/snippets/authelia-authrequest.conf;

		proxy_pass http://192.168.1.30:80;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header Connection "";

		client_max_body_size 0;
	}

	location /sdoc-server/ {
		include /etc/nginx/snippets/proxy.conf;

		proxy_pass         http://192.168.1.30:8888/;
		client_max_body_size 100m;
	}

	location /socket.io {
		include /etc/nginx/snippets/websocket.conf;

		proxy_pass http://192.168.1.30:8888;
		proxy_redirect off;

		proxy_buffer_size 64k;
		proxy_buffers 8 32k;
		proxy_busy_buffers_size 64k;
		proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
		proxy_set_header Host $http_host;
		proxy_set_header X-NginX-Proxy true;
	}

	location /notification/ping {
	    proxy_pass http://192.168.1.30:8083/ping;
	    access_log      /var/log/nginx/notification.access.log seafileformat;
	    error_log       /var/log/nginx/notification.error.log;
	}

	location /notification {
		include /etc/nginx/snippets/proxy.conf;	 
		include /etc/nginx/snippets/websocket.conf;

		proxy_pass http://192.168.1.30:8083;
		access_log      /var/log/nginx/notification.access.log seafileformat;
		error_log       /var/log/nginx/notification.error.log;
	}

    ssl_certificate /etc/letsencrypt/live/seafile.crenam.space/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/seafile.crenam.space/privkey.pem; # managed by Certbot
}
