]> Untitled Git - lemmy.git/commitdiff
Fix nginx config for local federation setup (#104)
authornutomic <nutomic@noreply.yerbamate.dev>
Thu, 24 Sep 2020 13:50:38 +0000 (13:50 +0000)
committerdessalines <dessalines@noreply.yerbamate.dev>
Thu, 24 Sep 2020 13:50:38 +0000 (13:50 +0000)
Fix depends_on

Add note about different port for backend in federation docs

Fix nginx config for local federation setup

Co-authored-by: Felix Ableitner <me@nutomic.com>
Reviewed-on: https://yerbamate.dev/LemmyNet/lemmy/pulls/104

docker/federation/docker-compose.yml
docker/federation/nginx.conf
docs/src/contributing_federation_development.md

index 2a6e24b248884bff543fbbf8b644ccecdb7bfdae..b4181e5d2d3a1a0d4424444be081f535ac9a3d57 100644 (file)
@@ -15,11 +15,11 @@ services:
     depends_on:
       - pictrs
       - iframely
-      - lemmy-alpha
-      - lemmy-beta
-      - lemmy-gamma
-      - lemmy-delta
-      - lemmy-epsilon
+      - lemmy-alpha-ui
+      - lemmy-beta-ui
+      - lemmy-gamma-ui
+      - lemmy-delta-ui
+      - lemmy-epsilon-ui
 
   pictrs:
     restart: always
index f787a9d2f8225d866595ba4cf633e49f8e9c5bb7..003f88dc027b1712e28d027c461a838e04cb85a9 100644 (file)
@@ -3,6 +3,12 @@ events {
 }
 
 http {
+    upstream lemmy-alpha {
+        server "lemmy-alpha:8541";
+    }
+    upstream lemmy-alpha-ui {
+        server "lemmy-alpha-ui:1234";
+    }
     server {
         listen 8540;
         server_name 127.0.0.1;
@@ -11,14 +17,19 @@ http {
         # Upload limit for pictshare
         client_max_body_size 50M;
 
-        location /api/v1 {
-            proxy_pass http://lemmy-alpha:8541/api/v1;
+        location ~ ^/(api|docs|pictrs|feeds|nodeinfo|.well-known) {
+            proxy_pass http://lemmy-alpha;
             proxy_http_version 1.1;
             proxy_set_header Upgrade $http_upgrade;
             proxy_set_header Connection "upgrade";
         }
         location / {
-            proxy_pass http://lemmy-alpha-ui:1234;
+            set $proxpass http://lemmy-alpha-ui;
+            if ($http_accept = "application/activity+json") {
+              set $proxpass http://lemmy-alpha;
+            }
+            proxy_pass $proxpass;
+
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header Host $host;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -34,6 +45,12 @@ http {
         }
     }
 
+    upstream lemmy-beta {
+        server "lemmy-beta:8551";
+    }
+    upstream lemmy-beta-ui {
+        server "lemmy-beta-ui:1234";
+    }
     server {
         listen 8550;
         server_name 127.0.0.1;
@@ -42,14 +59,19 @@ http {
         # Upload limit for pictshare
         client_max_body_size 50M;
 
-        location /api/v1 {
-            proxy_pass http://lemmy-beta:8551/api/v1;
+        location ~ ^/(api|docs|pictrs|feeds|nodeinfo|.well-known) {
+            proxy_pass http://lemmy-beta;
             proxy_http_version 1.1;
             proxy_set_header Upgrade $http_upgrade;
             proxy_set_header Connection "upgrade";
         }
         location / {
-            proxy_pass http://lemmy-beta-ui:1234;
+            set $proxpass http://lemmy-beta-ui;
+            if ($http_accept = "application/activity+json") {
+              set $proxpass http://lemmy-beta;
+            }
+            proxy_pass $proxpass;
+
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header Host $host;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -65,6 +87,12 @@ http {
         }
     }
 
+    upstream lemmy-gamma {
+        server "lemmy-gamma:8561";
+    }
+    upstream lemmy-gamma-ui {
+        server "lemmy-gamma-ui:1234";
+    }
     server {
         listen 8560;
         server_name 127.0.0.1;
@@ -73,14 +101,19 @@ http {
         # Upload limit for pictshare
         client_max_body_size 50M;
 
-        location /api/v1 {
-            proxy_pass http://lemmy-gamma:8561/api/v1;
+        location ~ ^/(api|docs|pictrs|feeds|nodeinfo|.well-known) {
+            proxy_pass http://lemmy-gamma;
             proxy_http_version 1.1;
             proxy_set_header Upgrade $http_upgrade;
             proxy_set_header Connection "upgrade";
         }
         location / {
-            proxy_pass http://lemmy-gamma-ui:1234;
+            set $proxpass http://lemmy-gamma-ui;
+            if ($http_accept = "application/activity+json") {
+              set $proxpass http://lemmy-gamma;
+            }
+            proxy_pass $proxpass;
+
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header Host $host;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -96,6 +129,12 @@ http {
         }
     }
 
+    upstream lemmy-delta {
+        server "lemmy-delta:8571";
+    }
+    upstream lemmy-delta-ui {
+        server "lemmy-delta-ui:1234";
+    }
     server {
         listen 8570;
         server_name 127.0.0.1;
@@ -104,14 +143,19 @@ http {
         # Upload limit for pictshare
         client_max_body_size 50M;
 
-        location /api/v1 {
-            proxy_pass http://lemmy-delta:8571/api/v1;
+        location ~ ^/(api|docs|pictrs|feeds|nodeinfo|.well-known) {
+            proxy_pass http://lemmy-delta;
             proxy_http_version 1.1;
             proxy_set_header Upgrade $http_upgrade;
             proxy_set_header Connection "upgrade";
         }
         location / {
-            proxy_pass http://lemmy-delta-ui:1234;
+            set $proxpass http://lemmy-delta-ui;
+            if ($http_accept = "application/activity+json") {
+              set $proxpass http://lemmy-delta;
+            }
+            proxy_pass $proxpass;
+
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header Host $host;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
@@ -127,6 +171,12 @@ http {
         }
     }
 
+    upstream lemmy-epsilon {
+        server "lemmy-epsilon:8581";
+    }
+    upstream lemmy-epsilon-ui {
+        server "lemmy-epsilon-ui:1234";
+    }
     server {
         listen 8580;
         server_name 127.0.0.1;
@@ -135,14 +185,19 @@ http {
         # Upload limit for pictshare
         client_max_body_size 50M;
 
-        location /api/v1 {
-            proxy_pass http://lemmy-epsilon:8581/api/v1;
+        location ~ ^/(api|docs|pictrs|feeds|nodeinfo|.well-known) {
+            proxy_pass http://lemmy-epsilon;
             proxy_http_version 1.1;
             proxy_set_header Upgrade $http_upgrade;
             proxy_set_header Connection "upgrade";
         }
         location / {
-            proxy_pass http://lemmy-epsilon-ui:1234;
+            set $proxpass http://lemmy-epsilon-ui;
+            if ($http_accept = "application/activity+json") {
+              set $proxpass http://lemmy-epsilon;
+            }
+            proxy_pass $proxpass;
+
             proxy_set_header X-Real-IP $remote_addr;
             proxy_set_header Host $host;
             proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
index 1d2436033cf6446dc01aa1d55619f2a8ded00c54..0c6fd9c4047613922ab5f8b8c3a166eb05cc1783 100644 (file)
@@ -21,10 +21,12 @@ lemmy-epsilon | lemmy_epsilon | [127.0.0.1:8580](http://127.0.0.1:8580) | uses b
 
 You can log into each using the instance name, and `lemmy` as the password, IE (`lemmy_alpha`, `lemmy`). 
 
-To start federation between instances, visit one of them and search for a user, community or post, like this:
-- `!main@lemmy-alpha:8540`
-- `http://lemmy-beta:8550/post/3`
-- `@lemmy-gamma@lemmy-gamma:8560`
+To start federation between instances, visit one of them and search for a user, community or post, like this. Note that
+the Lemmy backend runs on a different port than the frontend, so you have to increment the port number from 
+the URL bar by one.
+- `!main@lemmy-alpha:8541`
+- `http://lemmy-beta:8551/post/3`
+- `@lemmy-gamma@lemmy-gamma:8561`
 
 Firefox containers are a good way to test them interacting.