• nginx安装、部署前端、请求转发


    1、安装可以参考这篇博客

    2、部署前端程序

     location /
             {
                root   /var/www/dist;  # 前端程序所在路径
                index  index.html index.htm;  # 指定请求的首页html
            }

    3、转发,请关注着色部分

     server {
            listen       80;
            server_name  localhost;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
            #部署前端的程序
            location /
             {
                root   /var/www/dist;
                index  index.html index.htm;
            }
    
            #转发使用 
            location /docs {
            #将http://132.232.44.72:8080/docs/访问地址转发到  http://132.232.44.72:80/docs/这个地址       
                    proxy_pass http://132.232.44.72:8080/docs/;
             }
            #error_page  404              /404.html;
            # redirect server error pages to the static page /50x.html
            #
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
    }

    4、开启多个端口服务

     server {
            listen       80;
            server_name  localhost;
    
            #charset koi8-r;
    
            #access_log  logs/host.access.log  main;
            #部署前端的程序
            location /
             {
                root   /var/www/dist;
                index  index.html index.htm;
            }
    
            #转发使用 
            location /docs {
            #将http://132.232.44.72:8080/docs/访问地址转发到  http://132.232.44.72:80/docs/这个地址       
                    proxy_pass http://132.232.44.72:8080/docs/;
             }
            #error_page  404              /404.html;
            # redirect server error pages to the static page /50x.html
            #
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   html;
            }
    }
    ###开启 8000端口 server { listen
    8000; server_name localhost; location /examples { proxy_pass http://localhost:8080/examples/; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } }

    完毕

  • 相关阅读:
    3.4、Python中的类详解(0601)
    3.3、Python函数详解(0601)
    3.2、Python函数详解(0601)
    3.1、Python中的正则表达式(0601)
    2.4、Python文件对象及os、os.path和pickle模块(0530)
    2.3、Python迭代器、列表解析及生成器(0530)
    2.2、Python程序控制结构(0530)
    PHP之pear包总结
    Mac之brew使用
    Node之安装篇
  • 原文地址:https://www.cnblogs.com/ywjfx/p/12575196.html
Copyright © 2020-2023  润新知