首页 > 系统相关 >nginx url地址重写与转发

nginx url地址重写与转发

时间:2022-10-12 15:08:29浏览次数:39  
标签:http url nginx api ws location interface 重写


nginx url地址重写与转发_nginx

1.  去掉地址中的/api部分

location /api/ws{
        rewrite "^/api(.*)$" $1;
    }

2.  /ws地址将转发http://47.119.131.185

location /ws {
        proxy_pass http://47.119.131.185;  
    } 

3.  转换/api/interface为/interface并转发到https://siwei.me

location /api/interface{
        rewrite "^/api(.*)$" $1;
    }
    location /interface{
            proxy_pass http://siwei.me;
    }

要测试上面的修改  nginx -t

要使用上面的修改生效  nginx -s reload

 

标签:http,url,nginx,api,ws,location,interface,重写
From: https://blog.51cto.com/u_15826192/5750745

相关文章

  • java重写(Override)&重载
    /***obj_1*Java继承*动物类*/publicclassAnimal{privateStringname;privateintid;publicAnimal(StringmyName,intmyid){name=my......
  • Pytest插件之pytest-base-url切换测试环境
    Pytest插件之pytest-base-url切换测试环境安装 pipinstallpytest-base-url 应用场景利用参数--base-url或者配置(pytest.ini中base_url)来切换url用法:命令......
  • nginx配置——根据路由参数来设置对应响应方式
      location/{set$is_matched0;#是否有匹配的参数#正则判断url中携带的参数是否有匹配if($query_string~".*(?:^|\?|&)token=123"){set$is_ma......
  • CENTOS安装NGINX报错
    1特别是在CentOS7上安装Nginx,不确定你有什么样的错误(无法打开你的图像/图片),但刚刚在CentOS7上尝试过(大约10分钟前)(VagrantBox"CentOS-7.2-1.8T"),它通过......
  • nginx负载均衡策略
    目前Nginx服务器的upstream模块支持6种方式的分配:轮询默认方式weight权重方式ip_hash依据ip分配方式least_conn最少连接方式fair(第三方)响应时间方......
  • centos7 安装 Nginx 步骤
    1安装gcc2安装perl库yuminstall-ypcrepcre-devel3安装zlib库yuminstall-yzlibzlib-devel4先解压,然后到文件夹里面./configure--prefix=/usr/local/nginx......
  • 为什么选择 Kotlin 重写后端服务?
    目录​​1.确定适用的技术栈​​​​2.选择适合的编程语言​​​​Kotlin优点:​​​​软件库生态系统强大​​​​对gRPC、HTTP、Kafka、Cassandr和SQL提供一等支持​​......
  • nginx 配置一个域名多个项目
    server{listen80;listen[::]:80;server_namexxxxx.cn;proxy_intercept_errorson;indexindex.htmlindex.htm;#root/raray/wwwroot;error......
  • Servlet Servlet生命周期、java用swith取代多个if else、重载与重写、AJAX定义、应用
    大家可分享关于Java微服务相关知识,包括但不限于Java微服务开发经验、架构组成、技术交流、中间件等内容,我们鼓励springcloud架构为基础发散出击,从而达到技术积累的目的,快来......
  • nginx笔记
    场景一:请求时header中参数带有下划线‘_’时Nginx转发后此类参数丢失。原因:nginx默认request的header中包含’_’时,会自动忽略掉。解决方案:1、header参数不使......