利用Caddy替代nginx做代理服务器

it不难
2022-06-29 / 0 评论 / 10 阅读 / 正在检测是否收录...

前言

部署

系统基本配置

参考: docker和docker-compose一键安装脚本

docker-compose.yml

version: "3.8"

services:
  caddy:
    image: caddy:latest
    restart: always
    ports:
      - '80:80'
      - '443:443'
    environment:
      - 'SET_CONTAINER_TIMEZONE=true'
      - 'TZ=Asia/Shanghai'
    volumes:
      - ./conf:/etc/caddy
      - /opt/www/dl:/opt/www/dl
      - /var/log/caddy:/opt/logs
    networks:
      - caddy_net

networks:
  caddy_net:

Caddyfile配置

dl.itbunan.xyz {
  encode zstd gzip
  root * /opt/www/dl
  file_server
}

webzhan.xyz {
  tls admin@webzhan.xyz
  encode gzip
  log {
      output file  /opt/logs/access.log
  }
  header / {
      Strict-Transport-Security "max-age=31536000;includeSubdomains;preload"
  }

  ## HTTP 代理配置
  reverse_proxy  fmail:3000
}

v.webzhan.xyz {
  tls admin@webzhan.xyz
  encode gzip
  log {
      output file  /opt/logs/v_access.log
  }

  reverse_proxy 172.23.0.1:81

  file_server

  handle_errors {
      root * /etc/caddy/error
      rewrite * /error.html
      templates
      file_server
  }
}

v.webzhan.xyz {
  root * /www/web/v/
  tls admin@webzhan.xyz
  encode gzip
  log {
      output file  /opt/logs/v_access.log
  }

  php_fastcgi php:9000 {
     split .php
     index index.php
  }

  file_server

  handle_errors {
      root * /opt/caddy/error
      rewrite * /error.html
      templates
      file_server
  }
}
0

评论 (0)

取消