欢迎光临
我们一直在努力

nginx反代sqtracker配置

注释掉traefik的相关配置:

services:
  traefik:
    image: "traefik:v2.5"
    container_name: "sq_traefik"
    command:
      - "--api.insecure=true"
      - "--providers.file=true"
      - "--providers.file.filename=/config/traefik.yml"
      - "--entrypoints.webinsecure.address=:80"
      - "--entrypoints.web.address=:443"
      - "--entryPoints.web.proxyProtocol.insecure"
      - "--entryPoints.web.forwardedHeaders.insecure"
      - "--certificatesresolvers.tlsresolver.acme.email=example.com"
      - "--certificatesresolvers.tlsresolver.acme.storage=/letsencrypt/acme.json"
      - "--certificatesresolvers.tlsresolver.acme.httpchallenge=true"
      - "--certificatesresolvers.tlsresolver.acme.httpchallenge.entrypoint=webinsecure"
    ports:
      - "80:80"
      - "443:443"
      - "8080:8080"
    volumes:
      - "/var/run/docker.sock:/var/run/docker.sock:ro"
      - ./letsencrypt:/letsencrypt
      - ./traefik.yml:/config/traefik.yml

新建nginx配置文件:

nano /etc/nginx/sites-available/sqtracker

写入如下配置:

server {
    listen 80;
    server_name sqtracker.example.com;
    client_max_body_size 0;

    location / {
        proxy_pass http://127.0.0.1:3000;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    location /api/ {
        proxy_pass http://127.0.0.1:3001/;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }

    location /sq/ {
        proxy_pass http://127.0.0.1:3001;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

启用新的nginx配置:

ln -s /etc/nginx/sites-available/sqtracker /etc/nginx/sites-enabled/sqtracker

签发ssl证书:

certbot --nginx

看下api容器的log:

docker compose logs -f api

如果回显有200状态码,并且能够显示出访客的公网ip说明正常:

LALA

我什么都不卖了,告辞!

赞(0)
未经允许不得转载:拆东墙 » nginx反代sqtracker配置

评论 抢沙发

登录

找回密码

注册