nginx反向代理实现二级域名转一级域名
生活随笔
收集整理的這篇文章主要介紹了
nginx反向代理实现二级域名转一级域名
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
- 需求場景:
后續(xù)域名僅需按項目維護
- 實現(xiàn)方式
采用nginx反向代理,注意項目內路徑的設置問題,本次遇見的問題均有路由錯誤導致,供參考
備注:
服務nginx配置文件參考如下:
server {listen 8080 default_server;listen [::]:8080 default_server;server_name nginx_vue_front;gzip on;gzip_min_length 1k;gzip_comp_level 9;gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css application/font-sfnt;gzip_disable "MSIE [1-6]\.";gzip_vary on;root /www/wwwroot/dist/;location / {try_files $uri $uri/ /index.html;}location ~* ^.+\.(eot|ttf|otf|woff|svg)$ {access_log off;add_header Cache-Control max-age=360000;} }dockerfile參考如下:
/www/wwwroot # cat Dockerfile FROM node:12.18.0-alpine3.11ARG NPM_RUN_ARG=build RUN apk add nginx tzdata RUN cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtimeADD . /www/wwwroot/ WORKDIR /www/wwwroot/ RUN yarn config set registry https://registry.npm.taobao.org/ && yarn install && yarn cache clean RUN npm run --silent $NPM_RUN_ARG RUN ln -s /www/wwwroot/deploy/nginx.conf /etc/nginx/conf.d/ RUN rm -f /etc/nginx/mime.types; ln -s /www/wwwroot/deploy/mime.types /etc/nginx/CMD ["/usr/sbin/nginx", "-g", "pid /tmp/nginx.pid; daemon off;"]總結
以上是生活随笔為你收集整理的nginx反向代理实现二级域名转一级域名的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: iPhone 13锁屏无法收到微信通知提
- 下一篇: 文献管理软件 Endnote 简易上手