├── logs └── .gitkeep ├── mongodb └── .gitkeep ├── rabbitmq └── .gitkeep ├── storage └── .gitkeep ├── nginx ├── certificates │ └── .gitkeep └── templates │ └── default.conf.template ├── .gitignore ├── oss └── image-styles.txt ├── Makefile ├── docker-compose.gpu.yml ├── LICENSE ├── .env.sample ├── docker-compose.dev.yml ├── README.md ├── .github └── workflows │ └── update-labelplus-releases.yml ├── .env-backend.sample └── docker-compose.yml /logs/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /mongodb/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /rabbitmq/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /storage/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /nginx/certificates/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /mongodb/** 2 | /nginx/certificates/** 3 | /rabbitmq/** 4 | /logs/** 5 | /storage/** 6 | .env* 7 | !.env*.sample 8 | !.gitkeep 9 | 10 | .DS_Store 11 | -------------------------------------------------------------------------------- /oss/image-styles.txt: -------------------------------------------------------------------------------- 1 | styleName:cover,styleBody:image/auto-orient,1/interlace,1/resize,m_fill,w_180,h_140/quality,q_90/format,jpg 2 | styleName:safe-check,styleBody:image/auto-orient,1/interlace,1/resize,m_pad,w_400,h_500/quality,q_90/format,jpg -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | LOG_LEVEL := INFO 2 | # LOG_LEVEL := DEBUG 3 | 4 | 5 | BACKEND_REPO := ../moeflow-backend 6 | FRONTEND_REPO = ../moeflow-frontend 7 | 8 | dev-deps: 9 | exec docker-compose -f docker-compose.yml -f docker-compose.dev.yml up moeflow-mongodb moeflow-rabbitmq mongo-gui 10 | 11 | frontend-dev: 12 | cd $(FRONTEND_REPO) && npm run build:locale && exec npm start 13 | 14 | backend-dev: 15 | cd $(BACKEND_REPO) && make babel-update-mo && exec venv/bin/gunicorn -t 120 -w 4 --reload -b 127.0.0.1:5200 --log-level=${LOG_LEVEL} "app:create_app()" 16 | 17 | backend-worker: 18 | cd $(BACKEND_REPO) && exec venv/bin/celery --app app.celery worker --queues default,output --hostname celery.default --loglevel=${LOG_LEVEL} 19 | -------------------------------------------------------------------------------- /docker-compose.gpu.yml: -------------------------------------------------------------------------------- 1 | services: 2 | moeflow-celery-mit: 3 | image: ${GHCR_DOMAIN}/${MOEFLOW_MIT_WORKER_IMAGE:-UNSET}:${MOEFLOW_MIT_WORKER_VERSION:-UNSET} 4 | restart: unless-stopped 5 | volumes: 6 | - ./storage:/app/storage 7 | env_file: 8 | - '.env-mit-worker' 9 | entrypoint: bash 10 | command: 11 | - -uexc 12 | - | 13 | exec conda run -n mit-py311 --no-capture-output celery --app moeflow_worker worker --queues mit --loglevel=debug --concurrency=1 14 | links: [moeflow-rabbitmq, moeflow-mongodb] 15 | profiles: [mit-worker] 16 | depends_on: *backend-deps 17 | deploy: 18 | resources: 19 | reservations: 20 | devices: 21 | - driver: nvidia 22 | count: 1 23 | capabilities: 24 | - gpu 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2022 kozzzx 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /.env.sample: -------------------------------------------------------------------------------- 1 | # docker-compose env 2 | # 模板中值为 CHANGE_ME 的设置项涉及安全,请务必修改 3 | # ----------- 4 | # App 配置 5 | # ----------- 6 | # Docker Hub 仓库地址,国外服务器请填写 docker.io,国内服务器请填写镜像站 docker.nju.edu.cn 7 | DH_DOMAIN=docker.io 8 | # GHCR 仓库地址,国外服务器请填写 ghcr.io,国内服务器请填写镜像站 ghcr.nju.edu.cn 9 | GHCR_DOMAIN=ghcr.io 10 | # (可不修改) 在未来升级萌翻程序时修改版本号,并重新 docker-compose up 11 | # 建议非开发者只用有版本号的 `vx.y.z` image 12 | MOEFLOW_FRONTEND_IMAGE=moeflow-com/moeflow-frontend 13 | MOEFLOW_FRONTEND_VERSION=v1.1.7 14 | MOEFLOW_BACKEND_IMAGE=moeflow-com/moeflow-backend 15 | MOEFLOW_BACKEND_VERSION=v1.1.8 16 | 17 | # 【请修改】请填写您指向服务器的域名(不包含 www.)或 IP 地址。用于生成静态文件域名。 18 | DOMAIN=CHANGE_ME.moeflow.com 19 | 20 | # map nginx 80/443 to these ports 21 | HTTP_PORT=80 22 | HTTPS_PORT=443 23 | 24 | # Deps 25 | # (可不修改) MongoDB 账号,将在初次启动时设置 26 | MONGODB_USER=moeflow 27 | # 【请修改】MongoDB 密码,将在初次启动时设置 28 | MONGODB_PASS=CHANGE_ME 29 | # (可不修改) RabbitMQ 账号,将在初次启动时设置 30 | RABBITMQ_USER=moeflow 31 | # 【请修改】RabbitMQ 密码,将在初次启动时设置 32 | RABBITMQ_PASS=CHANGE_ME 33 | # (可不修改) APP 专用的 RabbitMQ Virtual Host 名称 34 | RABBITMQ_VHOST_NAME=moeflow 35 | 36 | # (可不修改) 允许上传文件的最大大小(MB),默认 1GB 37 | MAX_CONTENT_LENGTH_MB=1024 38 | 39 | # 可选的mit 翻译辅助worker 40 | # 目前不成熟,不建议开启 41 | # COMPOSE_PROFILES=mit-worker 42 | # MOEFLOW_MIT_WORKER_IMAGE=moeflow-com/manga-image-translator 43 | # MOEFLOW_MIT_WORKER_VERSION=sha-d0fed2d 44 | -------------------------------------------------------------------------------- /docker-compose.dev.yml: -------------------------------------------------------------------------------- 1 | services: 2 | moeflow-mongodb: 3 | ports: 4 | - 127.0.0.1:27017:27017 5 | 6 | moeflow-rabbitmq: 7 | ports: 8 | - 127.0.0.1:5672:5672 # AMQP 9 | - 127.0.0.1:15672:15672 # management UI 10 | 11 | mongo-gui: 12 | image: ugleiton/mongo-gui 13 | restart: unless-stopped 14 | ports: 15 | - "4321:4321" 16 | environment: 17 | MONGO_URL: mongodb://${MONGODB_USER}:${MONGODB_PASS}@moeflow-mongodb:27017/moeflow?authSource=admin 18 | logging: 19 | driver: none 20 | attach: false 21 | 22 | moeflow-backend: 23 | build: ../moeflow-backend # for local dev 24 | ports: 25 | - 127.0.0.1:5000:5000 26 | # TODO: should prepend `pip install` to gunicorn ? 27 | command: gunicorn -t 120 -w 1 --reload -b 0.0.0.0:5000 --log-level=DEBUG "app:create_app()" 28 | # environment: 29 | # LOG_LEVEL: DEBUG 30 | volumes: 31 | - ../moeflow-backend:/app # gets merged with docker-compose.yml 32 | 33 | moeflow-backend-init: 34 | command: python3 manage.py migrate 35 | 36 | moeflow-celery-default: 37 | command: celery --app app.celery worker --queues default --hostname celery.default --loglevel=debug 38 | 39 | moeflow-celery-output: 40 | command: celery --app app.celery worker --queues output --hostname celery.output --loglevel=debug 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # moeflow-deploy 2 | 3 | 用于自己部署萌翻服务的配置。 4 | 5 | 请参见部署视频演示 https://www.bilibili.com/video/BV1EX4y1J7MA/ 6 | 7 | ## docker compose 8 | 9 | 建议的部署方式。 10 | 11 | 0. 安装 [docker](https://docs.docker.com/engine/install/) 和 [docker-compose-plugin](https://docs.docker.com/compose/install/) 12 | - 注: 旧版本docker-compose可能无法正确设置环境变量. docker-compose-plugin v2.27.0 经测试可用. 13 | 1. 下载本repo的 [最新release](https://github.com/moeflow-com/moeflow-deploy/releases) 并解压 14 | - 非开发者不建议clone本repo: 代码最新状态可能和image不匹配 15 | 2. 将 `.env-backend.sample` 模板复制为 `.env-backend` ,并按模板内说明设置环境变量 16 | 3. 将 `.env.sample` 模板复制为 `.env` ,并按模板内说明设置环境变量 17 | 4. 运行 `docker compose up` 18 | 19 | ## FAQ 20 | 21 | ### 修改主页内容 22 | 23 | 升级前端版本至 `v1.0.3` 后端版本至 `v1.0.8` 后,即可在管理员页面-站点管理中,设置主页 HTML 和 CSS,以下为示例: 24 | 25 | 主页 HTML 26 | 27 | ```html 28 |
29 |

欢迎使用萌翻!

30 |

31 | 登陆 32 |

33 |

34 | 注册 35 |

36 |
37 | 38 | ``` 39 | 40 | 主页 CSS 41 | 42 | ```css 43 | html { 44 | width: 100%; 45 | height: 100%; 46 | } 47 | body { 48 | width: 100%; 49 | height: 100%; 50 | margin: 0; 51 | display: flex; 52 | flex-direction: column; 53 | justify-content: center; 54 | align-items: center; 55 | } 56 | .homepage-title { 57 | flex: auto; 58 | display: flex; 59 | flex-direction: column; 60 | justify-content: center; 61 | align-items: center; 62 | } 63 | .homepage-footer { 64 | height: 50px; 65 | text-align: center; 66 | } 67 | ``` 68 | -------------------------------------------------------------------------------- /.github/workflows/update-labelplus-releases.yml: -------------------------------------------------------------------------------- 1 | # Download labelplus latest releases, convert to .zip and upload to OSS 2 | 3 | name: Update labelplus latest releases 4 | 5 | on: 6 | workflow_dispatch: 7 | 8 | jobs: 9 | update: 10 | runs-on: ubuntu-latest 11 | steps: 12 | - name: Download Labelplus Release Assets 13 | uses: houqp/download-release-assets-action@v1.0.1 14 | with: 15 | repo: LabelPlus/LabelPlus 16 | match: "LabelPlus_.+" 17 | rename: LabelPlus_latest.7z 18 | 19 | - name: Download Labelplus Photoshop Script Release Assets 20 | uses: houqp/download-release-assets-action@v1.0.1 21 | with: 22 | repo: LabelPlus/PS-Script 23 | match: "LabelPlus_PS-Script_.+" 24 | rename: LabelPlus_PS-Script_latest.7z 25 | 26 | - run: sudo apt -y install atool 27 | - run: mkdir releases 28 | 29 | - run: arepack -e -F zip LabelPlus_latest.7z 30 | - run: mv LabelPlus_latest.zip releases/LabelPlus_latest.zip 31 | - run: arepack -e -F zip LabelPlus_PS-Script_latest.7z 32 | - run: mv LabelPlus_PS-Script_latest.zip releases/LabelPlus_PS-Script_latest.zip 33 | 34 | - name: Upload to oss 35 | id: upload_to_oss 36 | uses: tvrcgo/upload-to-oss@v0.1.1 37 | with: 38 | key-id: ${{ secrets.KOZZZX_FILES_OSS_KEY_ID }} 39 | key-secret: ${{ secrets.KOZZZX_FILES_OSS_KEY_SECRET }} 40 | region: oss-cn-shanghai 41 | bucket: kozzzx-files 42 | asset-path: ./releases 43 | target-path: /labelplus/ 44 | -------------------------------------------------------------------------------- /.env-backend.sample: -------------------------------------------------------------------------------- 1 | # upstream: https://github.com/moeflow-com/moeflow-backend/blob/main/.env.sample 2 | # with values set in docker-compose.yml commented out 3 | 4 | # Template of moeflow-backend env variables / 萌翻Backend的环境变量模板 5 | # values like `change_me` SHOULD be changed. They are related to security or basic functionality. 6 | # 模板中值为 CHANGE_ME 的设置涉及安全或基础功能,请一定在部署时修改 7 | 8 | # site name 9 | SITE_NAME=Moeflow 10 | SITE_ORIGIN=https://change_me.com 11 | 12 | # encrypt key of user sessions. 13 | SECRET_KEY=CHANGE_ME 14 | 15 | # auto-created admin user and password 16 | ADMIN_EMAIL=change_me@change_me.com 17 | ADMIN_INITIAL_PASSWORD=change_me 18 | 19 | # mongodb database 20 | # MONGODB_URI='mongodb://moeflow:PLEASE_CHANGE_THIS@moeflow-mongodb:27017/moeflow?authSource=admin' 21 | 22 | # celery job queue 23 | # CELERY_BROKER_URL="amqp://moeflow:PLEASE_CHANGE_THIS@moeflow-rabbitmq:5672/moeflow" 24 | 25 | # ----------- 26 | # Storage 配置 27 | # ----------- 28 | # 目前支持 LOCAL_STORAGE 和 OSS 29 | STORAGE_TYPE=LOCAL_STORAGE 30 | # STORAGE_DOMAIN: 返回给客户端的图片URL前缀 31 | # 1. 如果STORAGE_TYPE为OSS 32 | # - 未设置自定义域名则填写阿里云提供的 OSS 域名,格式如:https://..aliyuncs.com/ 33 | # - 如果绑定了 CDN 来加速 OSS,则填写绑定在 CDN 的域名 34 | # 2. 如果STORAGE_TYPE为LOCAL_STORAGE 35 | # - 本地储存填写绑定到服务器的域名+"/storage/",格式如:http(s)://.com/storage/, 36 | # STORAGE_DOMAIN=https://change_me.org/storage/ 37 | 38 | # size limit when uploading file in MB 39 | # MAX_CONTENT_LENGTH_MB=1024 40 | 41 | ## OSS_*: STORAGE_TYPE为OSS时的配置 42 | OSS_ACCESS_KEY_ID= 43 | OSS_ACCESS_KEY_SECRET= 44 | # OSS Endpoint(地域节点) 45 | # 含协议名,形如 https://oss-cn-shanghai.aliyuncs.com/ 46 | OSS_ENDPOINT= 47 | OSS_BUCKET_NAME= 48 | # (可不修改) OSS 图片处理规则名称 49 | OSS_PROCESS_COVER_NAME=cover 50 | OSS_PROCESS_SAFE_CHECK_NAME=safe-check 51 | 52 | # ----------- 53 | # CDN 配置 54 | # ----------- 55 | # 如果绑定了 CDN 来加速 OSS,且开启了 CDN 的[阿里云 OSS 私有 Bucket 回源]和[URL 鉴权], 56 | # 此时需要设置 OSS_VIA_CDN = True,并设置 CDN URL 鉴权主/备 KEY 57 | OSS_VIA_CDN=True 58 | CDN_URL_KEY_A= 59 | CDN_URL_KEY_B= 60 | 61 | # ----------- 62 | # Email 配置 63 | # ----------- 64 | # 是否发送用户邮件(验证码等) 65 | ENABLE_USER_EMAIL=False 66 | # 是否发送日志邮件 67 | ENABLE_LOG_EMAIL=False 68 | # SMTP 服务器地址 69 | EMAIL_SMTP_HOST= 70 | # SMTP 服务器端口 71 | EMAIL_SMTP_PORT= 72 | # 是否使用 SSL 连接 SMTP 服务器 73 | EMAIL_USE_SSL=True 74 | # 发件邮箱地址 75 | EMAIL_ADDRESS= 76 | # SMTP 服务器登陆用户名,通常是邮箱全称 77 | EMAIL_USERNAME= 78 | # SMTP 服务器登陆密码 79 | EMAIL_PASSWORD= 80 | # 用户回信邮箱地址 81 | EMAIL_REPLY_ADDRESS= 82 | # 网站错误报告邮箱地址 83 | EMAIL_ERROR_ADDRESS= 84 | 85 | # Options for experimental features. only enable if you know what you are doing. 86 | # MIT_STORAGE_ROOT=/app/storage 87 | # CELERY_BACKEND_URL='mongodb://moeflow:PLEASE_CHANGE_THIS@moeflow-mongodb:27017/moeflow?authSource=admin' 88 | -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | # default: use dockerd's logging options, maybe json 2 | x-logging-default: &logging_options {} 3 | 4 | # example: fluentd logging (uncomment #&logging_options to enable) 5 | x-logging-fluentd: # &logging_options 6 | driver: fluentd 7 | options: 8 | fluentd-address: "127.0.0.1:24224" 9 | fluentd-async: "true" 10 | tag: container-{{.Name}}-{{.ID}} 11 | 12 | # prefix other resource names (defaults to dir name) 13 | # name: moeflow-deploy 14 | 15 | services: 16 | moeflow-mongodb: 17 | image: ${DH_DOMAIN}/mongo:4.4.1 18 | restart: unless-stopped 19 | volumes: 20 | - ./mongodb/data/db:/data/db 21 | environment: 22 | MONGO_INITDB_ROOT_USERNAME: ${MONGODB_USER} 23 | MONGO_INITDB_ROOT_PASSWORD: ${MONGODB_PASS} 24 | command: ['--quiet', '--setParameter', 'logLevel=0'] 25 | logging: *logging_options 26 | healthcheck: 27 | # test: ["CMD","mongo", "--eval", "db.adminCommand('ping')"] 28 | test: ["CMD","bash", '-c', "exec 9<> /dev/tcp/127.0.0.1/27017"] 29 | interval: 15s 30 | timeout: 5s 31 | start_period: 10s 32 | 33 | moeflow-rabbitmq: 34 | image: ${DH_DOMAIN}/rabbitmq:3.8.9-management 35 | restart: unless-stopped 36 | volumes: 37 | - ./rabbitmq:/var/lib/rabbitmq 38 | environment: 39 | RABBITMQ_DEFAULT_USER: ${RABBITMQ_USER} 40 | RABBITMQ_DEFAULT_PASS: ${RABBITMQ_PASS} 41 | RABBITMQ_DEFAULT_VHOST: ${RABBITMQ_VHOST_NAME} 42 | logging: *logging_options 43 | healthcheck: 44 | test: rabbitmq-diagnostics -q ping 45 | interval: 5s 46 | timeout: 5s 47 | start_period: 10s 48 | 49 | moeflow-backend: &backend_base 50 | image: ${GHCR_DOMAIN}/${MOEFLOW_BACKEND_IMAGE}:${MOEFLOW_BACKEND_VERSION} 51 | command: gunicorn -t 120 -w 4 -b 0.0.0.0:5000 "app:create_app()" 52 | volumes: 53 | - ./storage:/app/storage 54 | - ./logs/moeflow-backend:/app/logs 55 | env_file: 56 | - .env-backend 57 | environment: 58 | # forward envs set in .env 59 | STORAGE_DOMAIN: https://${DOMAIN}/storage/ 60 | MONGODB_URI: mongodb://${MONGODB_USER}:${MONGODB_PASS}@moeflow-mongodb:27017/moeflow?authSource=admin 61 | CELERY_BROKER_URL: amqp://${RABBITMQ_USER}:${RABBITMQ_PASS}@moeflow-rabbitmq:5672/${RABBITMQ_VHOST_NAME} 62 | MAX_CONTENT_LENGTH_MB: ${MAX_CONTENT_LENGTH_MB} 63 | restart: unless-stopped 64 | logging: *logging_options 65 | depends_on: 66 | moeflow-backend-init: 67 | condition: service_completed_successfully 68 | 69 | moeflow-backend-init: 70 | <<: *backend_base 71 | command: python3 manage.py migrate 72 | restart: 'no' 73 | depends_on: &backend-deps 74 | moeflow-rabbitmq: 75 | condition: service_healthy 76 | moeflow-mongodb: 77 | condition: service_healthy 78 | 79 | moeflow-celery-default: 80 | <<: *backend_base 81 | command: celery --app app.celery worker --queues default --hostname celery.default --loglevel=info 82 | 83 | moeflow-celery-output: 84 | <<: *backend_base 85 | command: celery --app app.celery worker --queues output --hostname celery.output --loglevel=info 86 | 87 | moeflow-frontend: 88 | image: ${GHCR_DOMAIN}/${MOEFLOW_FRONTEND_IMAGE}:${MOEFLOW_FRONTEND_VERSION} 89 | restart: unless-stopped 90 | volumes: 91 | - ./nginx/templates:/etc/nginx/templates 92 | - ./nginx/certificates:/certificates 93 | - ./storage:/storage 94 | # - ../moeflow-frontend/build:/build 95 | ports: 96 | - "${HTTP_PORT}:80" 97 | - "${HTTPS_PORT}:443" 98 | environment: 99 | DOMAIN: ${DOMAIN} 100 | MAX_CONTENT_LENGTH_MB: ${MAX_CONTENT_LENGTH_MB} 101 | links: [moeflow-backend] 102 | logging: *logging_options 103 | -------------------------------------------------------------------------------- /nginx/templates/default.conf.template: -------------------------------------------------------------------------------- 1 | # =============== Config for non-SSL =============== 2 | 3 | # http://www.example.com -> http://example.com 4 | server { 5 | listen 80; 6 | server_name www.${DOMAIN}; 7 | return 301 http://${DOMAIN}$request_uri; 8 | } 9 | 10 | server { 11 | listen 80 default_server; 12 | server_name ${DOMAIN}; 13 | keepalive_timeout 70; 14 | client_max_body_size ${MAX_CONTENT_LENGTH_MB}M; 15 | 16 | location /api { 17 | # Flask api server 18 | proxy_pass http://moeflow-backend:5000/; 19 | 20 | add_header Cache-Control "no-cache"; 21 | gzip on; 22 | gzip_proxied any; 23 | 24 | proxy_set_header Host $host; 25 | proxy_set_header X-Real-IP $remote_addr; 26 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 27 | } 28 | 29 | location /storage { 30 | # no gzip for images 31 | if ($request_filename ~* ^.*?\.(txt|zip)$){ 32 | add_header Content-Disposition "attachment;"; 33 | } 34 | 35 | # Uncomment the following lines to allow CORS 36 | # add_header 'Access-Control-Allow-Origin' '*'; 37 | # add_header 'Access-Control-Allow-Credentials' 'true'; 38 | # add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; 39 | # add_header 'Access-Control-Allow-Headers' 'DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; 40 | # add_header 'Access-Control-Max-Age' 3600; 41 | 42 | alias /storage; 43 | } 44 | 45 | location / { 46 | # static assets 47 | root /build; 48 | try_files $uri /index.html; 49 | 50 | add_header Cache-Control "public, must-revalidate"; 51 | gzip on; 52 | gzip_types *; 53 | gzip_static on; 54 | gzip_proxied any; 55 | } 56 | } 57 | 58 | # =============== Config for SSL =============== 59 | 60 | # # http://(www.)example.com -> https://example.com 61 | # server { 62 | # listen 80; 63 | # server_name ${DOMAIN} www.${DOMAIN}; 64 | # return 301 https://${DOMAIN}$request_uri; 65 | # } 66 | 67 | # # https://www.example.com -> https://example.com 68 | # server { 69 | # listen 443 ssl; 70 | # server_name www.${DOMAIN}; 71 | # keepalive_timeout 70; 72 | 73 | # ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 74 | # ssl_ciphers AES128-SHA:AES256-SHA:RC4-SHA:DES-CBC3-SHA:RC4-MD5; 75 | # ssl_certificate /certificates/cert.pem; 76 | # ssl_certificate_key /certificates/cert.key; 77 | # ssl_session_cache shared:SSL:10m; 78 | # ssl_session_timeout 10m; 79 | 80 | # return 301 https://${DOMAIN}$request_uri; 81 | # } 82 | 83 | # server { 84 | # listen 443 ssl default_server; 85 | # server_name ${DOMAIN}; 86 | # keepalive_timeout 70; 87 | # client_max_body_size ${MAX_CONTENT_LENGTH_MB}M; 88 | 89 | # ssl_protocols TLSv1 TLSv1.1 TLSv1.2; 90 | # ssl_ciphers AES128-SHA:AES256-SHA:RC4-SHA:DES-CBC3-SHA:RC4-MD5; 91 | # ssl_certificate /certificates/cert.pem; 92 | # ssl_certificate_key /certificates/cert.key; 93 | # ssl_session_cache shared:SSL:10m; 94 | # ssl_session_timeout 10m; 95 | 96 | 97 | # location /api { 98 | # # Flask api server 99 | # proxy_pass http://moeflow-backend:5000/; 100 | 101 | # add_header Cache-Control "no-cache"; 102 | # gzip on; 103 | # gzip_proxied any; 104 | 105 | # proxy_set_header Host $host; 106 | # proxy_set_header X-Real-IP $remote_addr; 107 | # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 108 | # } 109 | 110 | # location /storage { 111 | # if ($request_filename ~* ^.*?\.(txt|zip)$){ 112 | # add_header Content-Disposition "attachment;"; 113 | # } 114 | # alias /storage; 115 | # } 116 | 117 | # location / { 118 | # root /build; 119 | # try_files $uri /index.html; 120 | # 121 | # add_header Cache-Control "public, must-revalidate"; 122 | # gzip on; 123 | # gzip_types *; 124 | # gzip_static on; 125 | # gzip_proxied any; 126 | # } 127 | # } 128 | --------------------------------------------------------------------------------