docker-compose部署yapi

遇到问题
  1. yapi跨域问题
    低版本的yapi确实存在跨域问题,但是现在官方出了一个google插件,所以不用nginx解决了所以可以不用搞了
  2. 附带nginx配置
    # cat nginx.conf
    server {
        listen       80;
        server_name localhost;
       # access_log  /data/log/nginx/yapi/access.log main;
    
        location / {
          proxy_pass  http://yapi-web:3000;
          proxy_set_header Host $host;
          proxy_set_header  X-Real-IP        $remote_addr;
          proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
          proxy_set_header X-NginX-Proxy true;
          proxy_set_header Connection "upgrade";
          proxy_set_header Upgrade $http_upgrade;
        }
    }
    
  3. 更多细节配置
    看jayfon的github或者gitee里面很详细 github gitee
补上yml
version: '3'
services:
  yapi-web:
    image: jayfong/yapi:latest
    container_name: yapi-web
    ports:
      - 3000:3000
   # volumes:
   #  - ./config.json:/yapi/config.json
    environment:
      - YAPI_ADMIN_ACCOUNT=admin@juneyaoair.com
      - YAPI_ADMIN_PASSWORD=admin
      - YAPI_CLOSE_REGISTER=true
      - YAPI_DB_SERVERNAME=yapi-mongo
      - YAPI_DB_PORT=27017
      - YAPI_DB_DATABASE=yapi
      - YAPI_MAIL_ENABLE=true
      - YAPI_LDAP_LOGIN_ENABLE=true
      - YAPI_PLUGINS=[]
    depends_on:
      - yapi-mongo
    privileged: true
    restart: always
    networks:
      - yapi-net
  yapi-mongo:
    image: mongo:latest
    container_name: yapi-mongo
    volumes:
      - ./data/db:/data/db
    expose:
      - 27017
	depends_on:
      - yapi-nginx
    privileged: true
    restart: always
    networks:
      - yapi-net
  yapi-nginx:
    image: nginx:latest
    container_name: yapi-nginx
    privileged: true
	restart: always
    ports:
      - 80:80
    environment:
      - NGINX_PORT=80
    networks:
      - yapi-net
    volumes:
      - ./nginx/configs/:/etc/nginx/conf.d/
networks:
  yapi-net:
    driver: bridge
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值