-
-
Save ToxicFrog/a3c31dbbc4222d079d1f69217d3f9759 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ config, pkgs, lib, ... }: | |
{ | |
services.nginx = { | |
enable = true; | |
recommendedProxySettings = true; | |
recommendedGzipSettings = true; | |
recommendedOptimisation = true; | |
recommendedTlsSettings = true; | |
virtualHosts."library.example.com" = { | |
# Automatically redirect HTTP requests to HTTPS | |
forceSSL = true; | |
# Automatically get certs from Let's Encrypt | |
enableACME = true; | |
# Reverse proxy / to ebook library | |
locations."/".proxyPass = "http://127.0.0.1:26657/"; | |
# Reverse proxy /comics to comic library | |
locations."/comics".proxyPass = "http://127.0.0.1:2202"; | |
# Inject some JS that improves the UI into all responses from the comic server, since | |
# this is easier than patching the server itself. | |
locations."= /comicreader.js".alias = pkgs.copyPathToStore ./comicreader.js; | |
# extraConfig lets you insert arbitrary nginx config, so you can e.g. override | |
# the proxy_set_header settings from recommendedProxySettings if needed, or | |
# do other weird stuff. | |
locations."/comics".extraConfig = '' | |
sub_filter '</head>' '<script type="text/javascript" src="/comicreader.js"></script></head>'; | |
sub_filter_last_modified on; | |
sub_filter_once on; | |
''; | |
}; | |
}; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment