nginx proxy_redirect指令功能


proxy_redirect

语法:proxy_redirect [ default|off|redirect replacement ] 
默认值:proxy_redirect default 
使用字段:http, server, location 
如果需要修改从被代理服务器传来的应答头中的”Location”和”Refresh”字段,可以用这个指令设置。
假设被代理服务器返回Location字段为: http://localhost:8000/two/some/uri/
这个指令:

proxy_redirect http://localhost:8000/two/ http://frontend/one/;

将Location字段重写为http://frontend/one/some/uri/。
在代替的字段中可以不写服务器名:

proxy_redirect http://localhost:8000/two/ /;

这样就使用服务器的基本名称和端口,即使它来自非80端口。

时间: 2024-08-25 19:02:26

nginx proxy_redirect指令功能的相关文章

keepalived+nginx安装配置

软件版本: pcre8.36 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.36.tar.gz keepalived1.2.19 http://www.keepalived.org/software/keepalived-1.2.19.tar.gz nginx1.8.0 http://nginx.org/download/nginx-1.8.0.tar.gz <pre name="code" class=

nginx和Tomcat集成后发生的重定向问题分析和解决

nginx和Tomcat集成后发生的重定向问题分析和解决 Tomcat前端配置一个HTTP服务器应该是大部分应用的标配了,基本思路就是所有动态请求都反向代理给后端的Tomcat,HTTP服务器来处 理静态请求,包括图片.js.css.html以及xml等.这样可以让你的应用的负载能力提高很多,前端这个HTTP服务器主流用的最多的当属 Apache HTTP Server和nginx.今天这篇文章主要讲解的是这种组合的方式的前提下,后端的Tomcat中的app在301跳转的时候遇到的一个问题. 问

nginx的proxy_redirect

proxy_redirect 语法:proxy_redirect [ default|off|redirect replacement ]; 默认:proxy_redirect default; 配置块:http.server.location 当上游服务器返回的响应是重定向或刷新请求(如HTTP响应码是301或者302)时,proxy_redirect可以重设HTTP头部的location或refresh字段. location /login { proxy_pass http://targe

nginx 反向代理之 proxy_redirect

proxy_redirect 该指令用来修改被代理服务器返回的响应头中的Location头域和“refresh”头域. 语法结构为: proxy_redirect redirect replacement; proxy_redirect default; proxy_redirect off; 错误示例: server { listen 80; server_name www.xxx.com; index index.html; location / { proxy_pass http://12

dns + nginx实现负载均衡

一 搭建环境说明: 服务器公网地址 用途 服务器内网地址 123.56.x.92 Nginx负载兼web服务 10.171.132.57 123.57.x.176 Nginx负载兼Web服务 10.172.235.86 两台服务器上面分别有三个站点,web,app,h5 1  PC站前端    nginx  80 2  H5站前端    nginx+tomcat  28180 3 app客户端   nginx+tomcat  28543 负载均衡实现方式和前提 准备用dns轮询解析来实现负载均衡

centos6 LNMP的搭建(linux+nginx+mysql+php)

LNMP的搭建(linux+nginx+mysql+php) 简介 LNMP代表的就是:Linux系统下Nginx+MySQL+PHP网站服务器架构. Linux是一类Unix计算机操作系统的统称,是目前最流行的免费操作系统.代表版本有:debian.centos.ubuntu.fedora.gentoo等. Nginx是一个高性能的HTTP和反向代理服务器,也是一个IMAP/POP3/SMTP代理服务器. Mysql是一个小型关系型数据库管理系统. PHP是一种在服务器端执行的嵌入HTML文档

nginx + tomcat配置https的两种方法

# The frist method: - Nginx and Tomcat using HTTPS: 1. nginx configuration: upstream test { server 172.16.7.30:8443 weight=1; } upstream master { server 172.16.7.31:8443 weight=1; } server { listen 80; server_name test.hbc315.com master.hbc315.com; r

Nginx反向代理的配置

Chapter: Nginx基本操作释疑 1. Nginx的端口修改问题 2. Nginx 301重定向的配置 3. Windows下配置Nginx使之支持PHP 4. Linux下配置Nginx使之支持PHP 5. 以源码编译的方式安装PHP与php-fpm 6. Nginx多站点配置的一次实践 7. Nginx反向代理的配置 Nginx 作为 web 服务器一个重要的功能就是反向代理.其实我们在前面的一篇文章<Nginx多站点配置的一次实践>里,用的就是 Nginx 的反向代理,这里简单再

Nginx对(apache+foreman+puppet)负载均衡

Nginx对(apache+foreman+puppet)负载均衡 一.前提准备 试验环境: OS:Centos 6.5_x86 puppet-server-3.8.3 foreman-1.9.2 foreman-proxy-1.9.2 httpd-2.2.15 服务器已经搭建好了apache+foreman+puppet详情请参考: http://4709096.blog.51cto.com/4699096/1710697 二.修改pupeptmaster相关配置 2.1修改puppetmas