• nginx安装,反向代理配置


    1.centos 版本

    下载最新稳定版 https://www.nginx.com/resources/wiki/start/topics/tutorials/install/#

    2.执行语句:

    ./configure
    make
    sudo make install

    如碰到./configure: error: the HTTP rewrite module requires the PCRE library. You can either disable the module by using --without-http_rewrite_module option, or install the PCRE library into the system, or build the PCRE library 问题,则执行

    yum install pcre
    yum install pcre-devel

    3.在安装目录下配置,本机是/usr/local/nginx/conf/nginx.conf。

    配置使用端口 listen 8081(默认80)

    4.测试配置文件是否可用

    /usr/local/nginx/sbin/nginx -t

    5.启动

    /usr/local/nginx/sbin/nginx

    6.在浏览器中访问

    其它常用命令:

    /usr/local/webserver/nginx/sbin/nginx -s reload            # 重新载入配置文件
    /usr/local/webserver/nginx/sbin/nginx -s reopen            # 重启 Nginx
    /usr/local/webserver/nginx/sbin/nginx -s stop              # 停止 Nginx

     配置反向代理

    需求:同一服务器中同一个tomcat下不同资源包之间的互通。

    nginx 端口:8081

    tomcat 端口:80

    nginx 配置文件中

    server下location配置如下

            location / {
             proxy_pass http://127.0.0.1:80/;
            }
    
            location /resource1 {
             rewrite /resource1/(.*) /resource2/$1 break;
             proxy_pass http://127.0.0.1:80/;
            }

    结果:

    127.0.0.1:8081/resouce1/* =》 实际获取的资源是是127.0.0.1:8081/resouce2/*

  • 相关阅读:
    [ts]类
    【跨域】jsonp的实现
    [ts]基础类型
    在Crystal Report中将数字转为英文
    合并 GridView 的单元格
    C#动态加载DLL
    在网页处理按键事件
    SQL Server 2005 中新CTE语法 递归性能测试
    连接远程服务器共享
    Asp.net 文件下载
  • 原文地址:https://www.cnblogs.com/guochunyi/p/5399692.html
Copyright © 2020-2023  润新知