透過 Docker 上的 nginx 代理程式時,Syncthing webGUI 損壞

透過 Docker 上的 nginx 代理程式時,Syncthing webGUI 損壞

我想使用 docker 在我的 Ubunty 18.04 伺服器上部署syncthing。

我使用 nginx 作為反向代理,因此 WebGUI 流量使用我的憑證透過 SSL 進行傳輸。然而,當透過 nginx 代理程式時開啟 webGUI 使其看起來像這樣https://i.stack.imgur.com/UdhYO.png

我在 Google 上發現了另一個人也遇到了這個問題,但沒有找到解決方案...有人知道怎麼回事嗎?

我的 docker-compose.yml:

version: '3'

services:

  nginx:
    image: nginx:latest
    container_name: nginx-1
    networks:
      - syncthing
    ports:
      - "80:80"
      - "443:443"
    restart: always
    volumes:
      - ./www:/var/www
      - ./nginx/:/etc/nginx
      - ./nginx/log:/var/log/nginx
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
    command: "/bin/sh -c 'while :; do sleep 6h & wait $${!}; nginx -s reload; done & nginx -g \"daemon off;\"'"

  syncthing:
    image: linuxserver/syncthing
    container_name: syncthing-1
    networks:
      - syncthing
    ports:
        #webUI 
      - 8384:8384
        #listening  
      - 22000:22000
        #port discovery
      - 21027:21027/udp
    restart: always
    volumes:
      - ./syncthing/config:/config
      - ./syncthing/data:/data
    environment:
      - TZ=CET

  letsencrypt:
    image: certbot/certbot
    command: renew
    container_name: letsencrypt-1
    networks:
      - le
    depends_on:
      - nginx
    restart: always
    volumes:
      - ./letsencrypt:/etc/letsencrypt
      - ./letsencrypt/log:/var/log/letsencrypt
      - /etc/localtime:/etc/localtime:ro
      - /var/run/docker.sock:/var/run/docker.sock:ro
    entrypoint: "/bin/sh -c 'trap exit TERM; while :; do certbot renew; sleep 12h & wait $${!}; done;'"


networks:
  syncthing:

以及我的啟用了 nginx 網站同步功能的檔案:

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;

    server_name example.com;
    root /;

    # SSL
    ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/example.com/chain.pem;

    # reverse proxy
    location /syncthing {
        proxy_pass http://syncthing:8384;

        proxy_read_timeout      600s;
        proxy_send_timeout      600s;    

        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

# HTTP redirect
server {
    listen 80;
    listen [::]:80;

    server_name example.com;

    location / {
        return 301 https://example.com$request_uri;
    }
}

相關內容