]> Untitled Git - lemmy.git/blobdiff - ansible/templates/nginx.conf
Isomorphic docker (#1124)
[lemmy.git] / ansible / templates / nginx.conf
index a978c18999a755efd31663d56b59bf82b9ef1c66..5c02eb137a4bef7f05ff2f25671688d87957c909 100644 (file)
@@ -1,4 +1,4 @@
-proxy_cache_path /var/cache/lemmy_frontend levels=1:2 keys_zone=lemmy_frontend_cache:10m max_size=100m                 use_temp_path=off;
+limit_req_zone $binary_remote_addr zone=lemmy_ratelimit:10m rate=1r/s;
 
 server {
     listen 80;
@@ -48,37 +48,56 @@ server {
     add_header X-Frame-Options "DENY";
     add_header X-XSS-Protection "1; mode=block";
 
-    # Upload limit for pictshare
-    client_max_body_size 50M;
+    # Upload limit for pictrs
+    client_max_body_size 20M;
 
+    # lemmy api
+    location /api/v1 {
+      proxy_pass http://0.0.0.0:8536/api/v1;
+      proxy_set_header X-Real-IP $remote_addr;
+      proxy_set_header Host $host;
+      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+
+      # Cuts off the trailing slash on URLs to make them valid
+      rewrite ^(.+)/+$ $1 permanent;
+
+      # WebSocket support
+      proxy_http_version 1.1;
+      proxy_set_header Upgrade $http_upgrade;
+      proxy_set_header Connection "upgrade";
+
+      # Rate limit
+      limit_req zone=lemmy_ratelimit burst=30 nodelay;
+    }
+
+    # Docs
+    location /docs {
+      proxy_pass http://0.0.0.0:8536/docs;
+      proxy_set_header X-Real-IP $remote_addr;
+      proxy_set_header Host $host;
+      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+    }
+
+    # lemmy-ui
     location / {
-        proxy_pass http://0.0.0.0:8536;
-        proxy_set_header X-Real-IP $remote_addr;
-        proxy_set_header Host $host;
-        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
-
-        # WebSocket support
-        proxy_http_version 1.1;
-        proxy_set_header Upgrade $http_upgrade;
-        proxy_set_header Connection "upgrade";
-
-        # Proxy Cache
-        proxy_cache             lemmy_frontend_cache;
-        proxy_cache_use_stale   error timeout http_500 http_502 http_503 http_504;
-        proxy_cache_revalidate  on;
-        proxy_cache_lock        on;
-        proxy_cache_min_uses    5;
-    }    
-
-    location /pictshare/ {
-      proxy_pass http://0.0.0.0:8537/;
+      proxy_pass http://0.0.0.0:1235;
       proxy_set_header X-Real-IP $remote_addr;
       proxy_set_header Host $host;
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+    }
+
 
-      if ($request_uri ~ \.(?:ico|gif|jpe?g|png|webp|bmp|mp4)$) {
-        add_header Cache-Control "public, max-age=31536000, immutable";
-      }   
+    # Redirect pictshare images to pictrs
+    location ~ /pictshare/(.*)$ {
+      return 301 /pictrs/image/$1;
+    }
+
+    # Separate location block to disable rate limiting for images
+    location /pictrs {
+      proxy_pass http://0.0.0.0:8536/pictrs;
+      proxy_set_header X-Real-IP $remote_addr;
+      proxy_set_header Host $host;
+      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     }
 
     location /iframely/ {