server { # h5要https是为了浏览器能够获取定位的权限 # 将这里的域名改成自己的域名 listen 443 ssl http2; listen [::]:443 ssl http2; server_name h5.mall4j.com; # 这一段是公有的ssl,需要将证书改成自己申请的证书 crt或pem格式的都可以 ssl_certificate /ssl/4664402_mall4j.com.crt; ssl_certificate_key /ssl/4664402_mall4j.com.key; ssl_session_timeout 1d; ssl_session_cache shared:MozSSL:10m; ssl_session_tickets off; ssl_protocols TLSv1.2 TLSv1.3; ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384; ssl_prefer_server_ciphers off; location / { # vue的 history 模式需要 # 对于h5,自提点等uniapp项目 # 如果location 是 / 那么对应的是try_files $uri $uri/ /; # 如果location 是 /h5 那么对应的是try_files $uri $uri/ /h5/; # 如果location 是 /xxx 那么对应的是try_files $uri $uri/ /xxx/; try_files $uri $uri/ /; # h5的路径存放到这里 /usr/share/nginx/html/cloud-h5 # 1.如果是docker部署的nginx,那么这个路径是docker里面的路径, # 服务器上的物理路径应该是 在docker-compose下的mall4j-nginx映射下 “./nginx/html:/usr/share/nginx/html” 也就是docker-compose的相对路径下的nginx/html文件夹 # 2. 如果是非docker部署,就是服务器的物理路径 # 如果location是/,那么root就要对应的代码路径咯 # 如果location是/h5,那么这个root就可以不用/h5了,也就是/usr/share/nginx/html root /usr/share/nginx/html/h5; index index.html; #### kill cache # 这里要清除缓存,不然微信会缓存首页,如果首页更改了代码,用户不清除微信缓存是获取不到新代码的 add_header Last-Modified $date_gmt; add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; if_modified_since off; expires off; etag off; add_header Cache-Control "no-store"; add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"; add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; add_header X-Content-Type-Options "nosniff"; # 如果觉得有必要的话,可以增加Content-Security-Policy,不过里面的域名要自己确定增加哪些 # add_header Content-Security-Policy "default-src 'self' https://cloud-api.mall4j.com wss://cloud-api.mall4j.com;img-src 'self' https://mall4cloud.oss-cn-guangzhou.aliyuncs.com data: blob:; style-src 'self' 'unsafe-inline';script-src 'self' 'unsafe-inline'"; } location /station { # vue的 history 模式需要 # 对于h5,自提点等uniapp项目 # 如果location 是 / 那么对应的是try_files $uri $uri/ /; # 如果location 是 /h5 那么对应的是try_files $uri $uri/ /h5/; # 如果location 是 /xxx 那么对应的是try_files $uri $uri/ /xxx/; try_files $uri $uri/ /; # h5的路径存放到这里 /usr/share/nginx/html/cloud-h5 # 1.如果是docker部署的nginx,那么这个路径是docker里面的路径, # 服务器上的物理路径应该是 在docker-compose下的mall4j-nginx映射下 “./nginx/html:/usr/share/nginx/html” 也就是docker-compose的相对路径下的nginx/html文件夹 # 2. 如果是非docker部署,就是服务器的物理路径 # 如果location是/,那么root就要对应的代码路径咯 # 如果location是/h5,那么这个root就可以不用/h5了,也就是/usr/share/nginx/html root /usr/share/nginx/html; index index.html; #### kill cache # 这里要清除缓存,不然微信会缓存首页,如果首页更改了代码,用户不清除微信缓存是获取不到新代码的 add_header Last-Modified $date_gmt; add_header Cache-Control 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'; if_modified_since off; expires off; etag off; add_header Cache-Control "no-store"; add_header Strict-Transport-Security "max-age=63072000; includeSubdomains; preload"; add_header X-Frame-Options "SAMEORIGIN"; add_header X-XSS-Protection "1; mode=block"; add_header X-Content-Type-Options "nosniff"; # 如果觉得有必要的话,可以增加Content-Security-Policy,不过里面的域名要自己确定增加哪些 # add_header Content-Security-Policy "default-src 'self' https://cloud-api.mall4j.com wss://cloud-api.mall4j.com;img-src 'self' https://mall4cloud.oss-cn-guangzhou.aliyuncs.com data: blob:; style-src 'self' 'unsafe-inline';script-src 'self' 'unsafe-inline'"; } }