跳转到主要内容

nginx

  • docker-compose.yaml
version: "3"
services:
  mobile-office-web:
    image: docker.io/nginx:latest
    restart: always # 自动重启
    privileged: true
    ports:
      - 9095:80
    # volumes:
    #   - ./html:/usr/share/nginx/html
    #   - ./default.conf:/etc/nginx/conf.d/default.conf
    environment:
      - TZ=Asia/Shanghai
  • default.conf
# touch default.conf

server {
    listen       80;
    #listen 443 ssl;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

    #ssl_certificate     /home/ssl/server.crt;
    #ssl_certificate_key /home/ssl/server.key;

    root /usr/share/nginx/html;
    index index.html;

    location / {
        proxy_pass http://project-web:3000;
        proxy_set_header  Host    $http_host;
        
        # 不缓存首页,解决VUE单页面发版后不生效
        add_header Cache-Control "no-cache no-store must-revalidate proxy-revalidate,max-age=0";
        add_header Last-Modified $date_gmt;
        etag off;
    }

   location /api {
        proxy_pass http://project-manager:8080;
        proxy_set_header  Host    $http_host;
    }

}