]> Untitled Git - lemmy.git/blob - docker/nginx.conf
add enable_federated_downvotes site option
[lemmy.git] / docker / nginx.conf
1 worker_processes 1;
2 events {
3     worker_connections 1024;
4 }
5 http {
6     upstream lemmy {
7         # this needs to map to the lemmy (server) docker service hostname
8         server "lemmy:8536";
9     }
10     upstream lemmy-ui {
11         # this needs to map to the lemmy-ui docker service hostname
12         server "lemmy-ui:1234";
13     }
14
15     server {
16         # this is the port inside docker, not the public one yet
17         listen 1236;
18         listen 8536;
19         # change if needed, this is facing the public web
20         server_name localhost;
21         server_tokens off;
22
23         gzip on;
24         gzip_types text/css application/javascript image/svg+xml;
25         gzip_vary on;
26
27         # Upload limit, relevant for pictrs
28         client_max_body_size 20M;
29
30         add_header X-Frame-Options SAMEORIGIN;
31         add_header X-Content-Type-Options nosniff;
32         add_header X-XSS-Protection "1; mode=block";
33
34         # frontend general requests
35         location / {
36             # distinguish between ui requests and backend
37             # don't change lemmy-ui or lemmy here, they refer to the upstream definitions on top
38             set $proxpass "http://lemmy-ui";
39
40             if ($http_accept = "application/activity+json") {
41               set $proxpass "http://lemmy";
42             }
43             if ($http_accept = "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"") {
44               set $proxpass "http://lemmy";
45             }
46             if ($request_method = POST) {
47               set $proxpass "http://lemmy";
48             }
49             proxy_pass $proxpass;
50
51             rewrite ^(.+)/+$ $1 permanent;
52             # Send actual client IP upstream
53             proxy_set_header X-Real-IP $remote_addr;
54             proxy_set_header Host $host;
55             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
56         }
57
58         # backend
59         location ~ ^/(api|pictrs|feeds|nodeinfo|.well-known) {
60             proxy_pass "http://lemmy";
61             # proxy common stuff
62             proxy_http_version 1.1;
63             proxy_set_header Upgrade $http_upgrade;
64             proxy_set_header Connection "upgrade";
65
66             # Send actual client IP upstream
67             proxy_set_header X-Real-IP $remote_addr;
68             proxy_set_header Host $host;
69             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
70         }
71     }
72 }