@cryptotaxi247 / infra / commits / 3f01600b

rhea: migrate from apache2 to nginx

Pierre Bourdon committed Jan 25, 2024 at 09:19 UTC 3f01600b99ecf81566aca1df3f36bc1438ef6c26
2 files changed +25 -61
delft/hydra-proxy.nix
+25 -61
@@ -1,71 +1,35 @@
1 { config, lib, pkgs, ...}:
2
3 -let
4 -
5 - hydraProxyConfig =
6 - ''
7 - TimeOut 900
8 -
9 - <Proxy *>
10 - Order deny,allow
11 - Allow from all
12 - </Proxy>
13 -
14 - ProxyRequests Off
15 - ProxyPreserveHost On
16 - ProxyPass /apache-errors !
17 - ProxyPass /.well-known !
18 - ErrorDocument 503 /apache-errors/503.html
19 - ProxyPass / http://127.0.0.1:3000/ retry=5 disablereuse=on
20 - ProxyPassReverse / http://127.0.0.1:3000/
21 -
22 - <Location />
23 - SetOutputFilter DEFLATE
24 - BrowserMatch ^Mozilla/4\.0[678] no-gzip\
25 - BrowserMatch \bMSI[E] !no-gzip !gzip-only-text/html
26 - SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png|narinfo)$ no-gzip dont-vary
27 - SetEnvIfNoCase Request_URI /api/ no-gzip dont-vary
28 - SetEnvIfNoCase Request_URI /download/ no-gzip dont-vary
29 - SetEnvIfNoCase Request_URI /nar/ no-gzip dont-vary
30 - </Location>
31 - '';
32 -
33 -in
34 -
3 {
36 -
37 - services.httpd = {
4 + services.nginx = {
5 enable = true;
39 - adminAddr = "edolstra@gmail.com";
40 - logFormat = ''"%h %l %u %t \"%r\" %>s %b %D"'';
41 - extraConfig = hydraProxyConfig +
42 - ''
43 - RewriteEngine On
44 - RewriteCond %{HTTPS} off
45 - RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
6 + enableReload = true;
7 +
8 + recommendedBrotliSettings = true;
9 + recommendedGzipSettings = true;
10 + recommendedOptimisation = true;
11 + recommendedProxySettings = true;
12 + recommendedTlsSettings = true;
13 + recommendedZstdSettings = true;
14 +
15 + proxyTimeout = "900s";
16 +
17 + virtualHosts."hydra.nixos.org" = {
18 + forceSSL = true;
19 + enableACME = true;
20 +
21 + extraConfig = ''
22 + error_page 503 /503.html;
23 + location = /503.html {
24 + root ${./nginx-error-pages};
25 + internal;
26 + }
27 '';
28
48 - virtualHosts."hydra.nixos.org" =
49 - { forceSSL = true;
50 - enableACME = true;
51 - extraConfig = ''
52 - # Required by Catalyst.
53 - RequestHeader set X-Forwarded-Proto https
54 - RequestHeader set X-Forwarded-Port 443
55 - Header always set Strict-Transport-Security "max-age=15552000"
56 -
57 - RewriteEngine On
58 - RewriteCond %{QUERY_STRING} ^query=pkgs.chromium$
59 - RewriteRule ^/search$ - [L,R=429,NC]
60 - '';
61 - listenAddresses = [ "[::]" ];
62 - servedDirs =
63 - [ { urlPath = "/apache-errors";
64 - dir = ./apache-errors;
65 - }
66 - ];
29 + locations."/" = {
30 + proxyPass = "http://127.0.0.1:3000";
31 };
68 -
32 + };
33 };
34
35 }
delft/nginx-error-pages/503.html renamed