Hi!
I’m using Nginx as reverse proxy and for a Gitea server, I’m trying to route SSH traffic through it. So I tried something like this:
services.nginx = {
enable = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
recommendedTlsSettings = true;
appendHttpConfig = ''
error_log stderr;
access_log syslog:server=unix:/dev/log combined;
'';
streamConfig = ''
server {
listen 22;
server_name git.mydomain.example;
proxy_pass localhost:222;
}
'';
}
However, after building said configuration, nginx.service failed to start with the error that “server_name” directive is not allowed here in /nix/store/-nginx.conf:. Excerpt from /nix/store/-nginx.conf:
stream {
server {
listen 22;
server_name git.mydomain.example; # <line-number> is here
proxy_pass localhost:222;
}
}
After searching a bit, I found that the error is usually caused by the stream module missing. So I checked the nixpkgs module but, as you can see, it is enabled by default.
I even tried to enable it explicitly with
services.nginx.package = (pkgs.nginx.override { withStream = true; });
but still no luck.
Any ideas what might be the problem?
Thank you in advance!