Skip to content

Commit

Permalink
fix(lemmy): use Nixpkgs provided Nginx config
Browse files Browse the repository at this point in the history
  • Loading branch information
dr460nf1r3 committed Dec 16, 2024
1 parent 288dfba commit 0214216
Showing 1 changed file with 2 additions and 63 deletions.
65 changes: 2 additions & 63 deletions nixos/hosts/lemmy.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
# Our Lemmy instance
services.lemmy = {
database.uri = "postgresql://lemmy:${garuda-lib.secrets.lemmy.database}@10.0.5.50/lemmy";
nginx.enable = true;
enable = true;
settings = {
hostname = "lemmy.garudalinux.org";
Expand All @@ -21,72 +22,10 @@
};
};

# Force newest version due to Nixpkgs having dropped 0.3.X.
# Force newest version due to Nixpkgs having dropped 0.3.X.
# Manual migration from 0.3.X -> 0.4.X -> 0.5.X has been performed.
# https://github.com/NixOS/nixpkgs/pull/336077
services.pict-rs.package = pkgs.pict-rs;

services.nginx = {
enable = true;
httpConfig = ''
map "$request_method:$http_accept" $proxpass {
# If no explicit matches exists below, send traffic to lemmy-ui
default "http://lemmy-ui";
# GET/HEAD requests that accepts ActivityPub or Linked Data JSON should go to lemmy
# "~^(?:GET|HEAD):.*?application\/(?:activity|ld)\+json" "http://lemmy";
# All non-GET/HEAD requests should go to lemmy
"~^(?!(GET|HEAD)).*:" "http://lemmy";
}
upstream lemmy {
server "127.0.0.1:8536";
}
upstream lemmy-ui {
server "127.0.0.1:1234";
}
server {
listen 80;
server_name lemmy.garudalinux.org;
server_tokens off;
gzip on;
gzip_types text/css application/javascript image/svg+xml;
gzip_vary on;
client_max_body_size 25M;
add_header X-Frame-Options SAMEORIGIN;
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
real_ip_header X-Real-IP;
set_real_ip_from 10.0.5.10;
# frontend general requests
location / {
proxy_pass $proxpass;
rewrite ^(.+)/+$ $1 permanent;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
}
# backend
location ~ ^/(api|pictrs|feeds|nodeinfo|.well-known) {
proxy_pass "http://lemmy";
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
}
}
'';
};

system.stateVersion = "23.05";
}

0 comments on commit 0214216

Please sign in to comment.