Différences
Ci-dessous, les différences entre deux révisions de la page.
si:lufi [2021/02/22 12:13] – créée dino | si:lufi [2021/02/22 12:14] (Version actuelle) – dino | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
+ | ====== Vhost pour le service Fichiers de Parinux ====== | ||
+ | |||
+ | ====== Port 80 avec let's encrypt ====== | ||
+ | |||
+ | < | ||
+ | |||
+ | server { | ||
+ | listen | ||
+ | server_tokens off; | ||
+ | |||
+ | |||
+ | server_name fichiers.parinux.org echanges.parinux.org transfert.parinux.org onenagros.parinux.org fichierslourds.parinux.org ; | ||
+ | access_log / | ||
+ | error_log / | ||
+ | |||
+ | location ~ / | ||
+ | # Set correct content type. According to this: | ||
+ | # https:// | ||
+ | # Current specification requires " | ||
+ | # It seems that " | ||
+ | default_type " | ||
+ | # This directory must be the same as in / | ||
+ | # as " | ||
+ | # there to " | ||
+ | # Do NOT use alias, use root! Target directory is located here: | ||
+ | # / | ||
+ | root / | ||
+ | } | ||
+ | location / { | ||
+ | return 301 https:// | ||
+ | proxy_pass http:// | ||
+ | proxy_set_header Host $host; | ||
+ | proxy_http_version 1.1; | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | |||
+ | |||
+ | ====== Port 443 et SSO via Oauth2 Proxy ====== | ||
+ | |||
+ | on peut concaténer partial|r|download | ||
+ | |||
+ | |||
+ | < | ||
+ | server { | ||
+ | listen 192.168.1.60: | ||
+ | server_name fichiers.parinux.org echanges.parinux.org transfert.parinux.org fichierslourds.parinux.org | ||
+ | access_log / | ||
+ | error_log / | ||
+ | |||
+ | ssl on; | ||
+ | ssl_certificate / | ||
+ | ssl_certificate_key / | ||
+ | server_tokens off; | ||
+ | |||
+ | index index index.html index.htm index.nginx-debian.html; | ||
+ | |||
+ | |||
+ | | ||
+ | | ||
+ | |||
+ | add_header Strict-Transport-Security " | ||
+ | |||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | | ||
+ | |||
+ | |||
+ | add_header X-Content-Type-Options nosniff; | ||
+ | add_header X-Frame-Options " | ||
+ | add_header X-XSS-Protection "1; mode=block"; | ||
+ | # add_header X-Robots-Tag none; | ||
+ | add_header X-Download-Options noopen; | ||
+ | add_header X-Permitted-Cross-Domain-Policies none; | ||
+ | |||
+ | location /r { | ||
+ | proxy_pass http:// | ||
+ | # Really important! Lufi uses WebSocket, it won't work without this | ||
+ | proxy_set_header Upgrade $http_upgrade; | ||
+ | proxy_set_header Connection " | ||
+ | |||
+ | proxy_http_version 1.1; | ||
+ | proxy_set_header Host $host; | ||
+ | proxy_set_header X-Real-IP $remote_addr; | ||
+ | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
+ | |||
+ | # If you want to log the remote port of the file senders, you'll need that | ||
+ | proxy_set_header X-Remote-Port $remote_port; | ||
+ | |||
+ | proxy_set_header X-Forwarded-Proto $scheme; | ||
+ | |||
+ | # We expect the downstream servers to redirect to the right hostname, so don't do any rewrites here. | ||
+ | proxy_redirect | ||
+ | |||
+ | } | ||
+ | |||
+ | |||
+ | location /partial { | ||
+ | proxy_pass http:// | ||
+ | # Really important! Lufi uses WebSocket, it won't work without this | ||
+ | proxy_set_header Upgrade $http_upgrade; | ||
+ | proxy_set_header Connection " | ||
+ | |||
+ | proxy_http_version 1.1; | ||
+ | proxy_set_header Host $host; | ||
+ | proxy_set_header X-Real-IP $remote_addr; | ||
+ | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
+ | |||
+ | # If you want to log the remote port of the file senders, you'll need that | ||
+ | proxy_set_header X-Remote-Port $remote_port; | ||
+ | |||
+ | proxy_set_header X-Forwarded-Proto $scheme; | ||
+ | |||
+ | # We expect the downstream servers to redirect to the right hostname, so don't do any rewrites here. | ||
+ | proxy_redirect | ||
+ | |||
+ | |||
+ | } | ||
+ | |||
+ | location /download { | ||
+ | proxy_pass http:// | ||
+ | # Really important! Lufi uses WebSocket, it won't work without this | ||
+ | proxy_set_header Upgrade $http_upgrade; | ||
+ | proxy_set_header Connection " | ||
+ | |||
+ | proxy_http_version 1.1; | ||
+ | proxy_set_header Host $host; | ||
+ | proxy_set_header X-Real-IP $remote_addr; | ||
+ | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | ||
+ | |||
+ | # If you want to log the remote port of the file senders, you'll need that | ||
+ | proxy_set_header X-Remote-Port $remote_port; | ||
+ | |||
+ | proxy_set_header X-Forwarded-Proto $scheme; | ||
+ | |||
+ | # We expect the downstream servers to redirect to the right hostname, so don't do any rewrites here. | ||
+ | proxy_redirect | ||
+ | |||
+ | |||
+ | } | ||
+ | |||
+ | location ~* ^/ | ||
+ | proxy_pass http:// | ||
+ | proxy_set_header Host $host; | ||
+ | proxy_http_version 1.1; | ||
+ | add_header Expires "Thu, 31 Dec 2037 23:55:55 GMT"; | ||
+ | add_header Cache-Control " | ||
+ | } | ||
+ | |||
+ | location /oauth2/ { | ||
+ | proxy_pass | ||
+ | proxy_set_header Host $host; | ||
+ | proxy_set_header X-Real-IP | ||
+ | proxy_set_header X-Scheme $scheme; | ||
+ | proxy_set_header X-Auth-Request-Redirect $request_uri; | ||
+ | # or, if you are handling multiple domains: | ||
+ | # proxy_set_header X-Auth-Request-Redirect $scheme:// | ||
+ | } | ||
+ | |||
+ | location = / | ||
+ | proxy_pass | ||
+ | proxy_set_header Host $host; | ||
+ | proxy_set_header X-Real-IP $remote_addr; | ||
+ | proxy_set_header X-Scheme $scheme; | ||
+ | # nginx auth_request includes headers but not body | ||
+ | proxy_set_header Content-Length | ||
+ | proxy_pass_request_body | ||
+ | } | ||
+ | |||
+ | location | ||
+ | auth_request / | ||
+ | error_page 401 = / | ||
+ | |||
+ | # # pass information via X-User and X-Email headers to backend, | ||
+ | # # requires running with --set-xauthrequest flag | ||
+ | auth_request_set $user | ||
+ | auth_request_set $email | ||
+ | proxy_set_header X-User | ||
+ | proxy_set_header X-Email $email; | ||
+ | |||
+ | # if you enabled --pass-access-token, | ||
+ | auth_request_set $token | ||
+ | proxy_set_header X-Access-Token $token; | ||
+ | |||
+ | # if you enabled --cookie-refresh, | ||
+ | auth_request_set $auth_cookie $upstream_http_set_cookie; | ||
+ | add_header Set-Cookie $auth_cookie; | ||
+ | |||
+ | # When using the --set-authorization-header flag, some provider' | ||
+ | # limit and so the OAuth2 Proxy splits these into multiple parts. | ||
+ | # Nginx normally only copies the first `Set-Cookie` header from the auth_request to the response, | ||
+ | # so if your cookies are larger than 4kb, you will need to extract additional cookies manually. | ||
+ | auth_request_set $auth_cookie_name_upstream_1 $upstream_cookie_auth_cookie_name_1; | ||
+ | |||
+ | # Extract the Cookie attributes from the first Set-Cookie header and append them | ||
+ | # to the second part ($upstream_cookie_* variables only contain the raw cookie content) | ||
+ | if ($auth_cookie ~* "(; .*)") { | ||
+ | set $auth_cookie_name_0 $auth_cookie; | ||
+ | set $auth_cookie_name_1 " | ||
+ | } | ||
+ | |||
+ | # Send both Set-Cookie headers now if there was a second part | ||
+ | if ($auth_cookie_name_upstream_1) { | ||
+ | add_header Set-Cookie $auth_cookie_name_0; | ||
+ | add_header Set-Cookie $auth_cookie_name_1; | ||
+ | } | ||
+ | |||
+ | # HTTPS only header, improves security | ||
+ | # | ||
+ | |||
+ | # Adapt this to your configuration (port, subdirectory (see below)) | ||
+ | | ||
+ | |||
+ | # Really important! Lufi uses WebSocket, it won't work without this | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | | ||
+ | |||
+ | # If you want to log the remote port of the file senders, you'll need that | ||
+ | | ||
+ | | ||
+ | |||
+ | # We expect the downstream servers to redirect to the right hostname, so don't do any rewrites here. | ||
+ | | ||
+ | } | ||
+ | } | ||
+ | </ | ||