diff --git a/docker/dev/docker-compose.yml b/docker/dev/docker-compose.yml index bc42d4562..2474c74d6 100644 --- a/docker/dev/docker-compose.yml +++ b/docker/dev/docker-compose.yml @@ -1,6 +1,16 @@ version: '3.3' services: + nginx: + image: nginx:1-alpine + ports: + - "1236:1236" + volumes: + - ./nginx.conf:/etc/nginx/nginx.conf + restart: always + depends_on: + - pictrs + - lemmy-ui lemmy: image: lemmy-dev:latest @@ -17,12 +27,10 @@ services: lemmy-ui: image: dessalines/lemmy-ui:dev - ports: - - "1235:1234" restart: always environment: - LEMMY_INTERNAL_HOST=lemmy:8536 - - LEMMY_EXTERNAL_HOST=localhost:8536 + - LEMMY_EXTERNAL_HOST=localhost:1234 - LEMMY_HTTPS=false depends_on: - lemmy @@ -42,8 +50,6 @@ services: pictrs: image: asonix/pictrs:v0.2.6-r2 - ports: - - "8537:8080" user: 991:991 volumes: - ./volumes/pictrs:/mnt diff --git a/docker/dev/nginx.conf b/docker/dev/nginx.conf new file mode 100644 index 000000000..dfc4c07b6 --- /dev/null +++ b/docker/dev/nginx.conf @@ -0,0 +1,51 @@ +worker_processes 1; +events { + worker_connections 1024; +} +http { + upstream lemmy { + server "lemmy:8536"; + } + upstream lemmy-ui { + server "lemmy-ui:1234"; + } + server { + listen 1236; + server_name localhost; + + # frontend + location / { + set $proxpass "http://lemmy-ui"; + if ($http_accept = "application/activity+json") { + set $proxpass "http://lemmy"; + } + if ($http_accept = "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\"") { + set $proxpass "http://lemmy"; + } + if ($request_method = POST) { + set $proxpass "http://lemmy"; + } + proxy_pass $proxpass; + + rewrite ^(.+)/+$ $1 permanent; + + # Send actual client IP upstream + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + # 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"; + + # Add IP forwarding headers + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + } +} diff --git a/docker/federation/docker-compose.yml b/docker/federation/docker-compose.yml index 3761ebadc..8b76a65a2 100644 --- a/docker/federation/docker-compose.yml +++ b/docker/federation/docker-compose.yml @@ -11,7 +11,7 @@ services: - "8580:8580" volumes: - ./nginx.conf:/etc/nginx/nginx.conf - restart: on-failure + restart: always depends_on: - pictrs - lemmy-alpha-ui