mirror of
https://codeberg.org/muon/home.git
synced 2025-12-06 08:07:45 +00:00
Fix lemmy nginx
This commit is contained in:
parent
ed26516625
commit
91519a558f
2 changed files with 36 additions and 32 deletions
|
|
@ -3,7 +3,7 @@ let
|
|||
inherit (lib) mkEnableOption;
|
||||
cfg = config.mods.server.lemmy;
|
||||
port = config.mods.server.local.ports.lemmy-api;
|
||||
port-ui = config.mods.server.nginx.ports.lemmy;
|
||||
port-ui = config.mods.server.local.ports.lemmy-ui;
|
||||
port-pict = config.mods.server.local.ports.pict-rs;
|
||||
hostname = "lemmy.muon.host";
|
||||
bind = "0.0.0.0";
|
||||
|
|
@ -42,40 +42,44 @@ in {
|
|||
address = "0.0.0.0";
|
||||
};
|
||||
|
||||
services.nginx.virtualHosts."${hostname}".locations = let
|
||||
services.nginx.virtualHosts."${hostname}" = let
|
||||
ui = "http://10.0.0.3:${toString port-ui}";
|
||||
backend = "http://10.0.0.3:${toString port}";
|
||||
in lib.mkIf config.mods.server.nginx.enable {
|
||||
"~ ^/(api|pictrs|feeds|nodeinfo|.well-known)" = {
|
||||
# backend requests
|
||||
proxyPass = backend;
|
||||
proxyWebsockets = true;
|
||||
recommendedProxySettings = true;
|
||||
};
|
||||
"/" = {
|
||||
# mixed frontend and backend requests, based on the request headers
|
||||
extraConfig = ''
|
||||
set $proxpass "${ui}";
|
||||
if ($http_accept = "application/activity+json") {
|
||||
set $proxpass "${backend}";
|
||||
}
|
||||
if ($http_accept = "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"") {
|
||||
set $proxpass "${backend}";
|
||||
}
|
||||
if ($request_method = POST) {
|
||||
set $proxpass "${backend}";
|
||||
}
|
||||
forceSSL = true;
|
||||
enableACME = true;
|
||||
locations = {
|
||||
"~ ^/(api|pictrs|feeds|nodeinfo|.well-known)" = {
|
||||
# backend requests
|
||||
proxyPass = backend;
|
||||
proxyWebsockets = true;
|
||||
recommendedProxySettings = true;
|
||||
};
|
||||
"/" = {
|
||||
# mixed frontend and backend requests, based on the request headers
|
||||
extraConfig = ''
|
||||
set $proxpass "${ui}";
|
||||
if ($http_accept = "application/activity+json") {
|
||||
set $proxpass "${backend}";
|
||||
}
|
||||
if ($http_accept = "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"") {
|
||||
set $proxpass "${backend}";
|
||||
}
|
||||
if ($request_method = POST) {
|
||||
set $proxpass "${backend}";
|
||||
}
|
||||
|
||||
# Cuts off the trailing slash on URLs to make them valid
|
||||
rewrite ^(.+)/+$ $1 permanent;
|
||||
# Cuts off the trailing slash on URLs to make them valid
|
||||
rewrite ^(.+)/+$ $1 permanent;
|
||||
|
||||
proxy_pass $proxpass;
|
||||
# Proxied `Host` header is required to validate ActivityPub HTTP signatures for incoming events.
|
||||
# The other headers are optional, for the sake of better log data.
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
'';
|
||||
proxy_pass $proxpass;
|
||||
# Proxied `Host` header is required to validate ActivityPub HTTP signatures for incoming events.
|
||||
# The other headers are optional, for the sake of better log data.
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue