测试需求,url自动加/后,发现重定向不带端口,即为 test.a.com:3443/abc  nginx自动重定向301到 test.a.com/abc,端口消失。

分析可能和nginx默认配置server_name_in_redirect 与 port_in_redirect 有关

1、server_name_in_redirect on(默认),URL 重定向为: server_name 中的第一个域名 + 目录名 + /;
2、server_name_in_redirect off,URL 重定向为: 原 URL 中的域名 + 目录名 + /。
If server_name_in_redirect is on, then Nginx will use the first value of the server_name directive for redirects. If server_name_in_redirect is off, then nginx will use the requested Host header.

更改nginx配置

server_name test.a.com:3443;
server_name_in_redirect on

即强制使用server_name得第一个域名,自己配置上端口

重启生效。

Syntax: server_name_in_redirect on | off;
Default:
server_name_in_redirect off;
Context: httpserverlocation

Enables or disables the use of the primary server name, specified by the server_name directive, in absolute redirects issued by nginx. When the use of the primary server name is disabled, the name from the “Host” request header field is used. If this field is not present, the IP address of the server is used.

Syntax: port_in_redirect on | off;
Default:
port_in_redirect on;
Context: httpserverlocation

Enables or disables specifying the port in absolute redirects issued by nginx.

The use of the primary server name in redirects is controlled by the server_name_in_redirect directive.

nginx url问题的更多相关文章

  1. nginx url自动加斜杠的问题

    nginx url自动加斜杠问题及301重定向 时间:2016-02-04 15:14:28来源:网络 导读:nginx url自动加斜杠问题及301重定向,URL指向一个目录并且在最后没有包含斜杠, ...

  2. 很不错的NGINX URL重写实例

    转自:http://www.jbxue.com/article/2187.html 本文介绍nginx URL重写的相关知识,包括301重定向的内容等,希望对大家有所帮助. nginx rewrite ...

  3. nginx url 重写 [转]

    本文转自 http://www.jbxue.com/article/2187.html 本文介绍nginx URL重写的相关知识,包括301重定向的内容等,希望对大家有所帮助. nginx rewri ...

  4. Nginx URL重写(rewrite)配置及信息详解

    URL重写有利于网站首选域的确定,对于同一资源页面多条路径的301重定向有助于URL权重的集中 Nginx URL重写(rewrite)介绍 和apache等web服务软件一样,rewrite的组要功 ...

  5. web服务器-Nginx URL重写

    web服务器-Nginx URL重写 一. URL重写介绍 和apache等web服务软件一样,rewrite的主要功能是实现URL地址的重定向.Nginx的rewrite功能需要PCRE软件的支持, ...

  6. nginx url重定向

    nginx内部支持url rewrite,内部编译进去了rewrite模块,nginx的rewrite模块类似于apache的rewriterule功能:支持多种规则和正则表达式: 详细介绍如下: N ...

  7. Nginx 笔记与总结(12)Nginx URL Rewrite 实例(ecshop)

    访问项目地址:http://192.168.254.100/ecshop 某个商品的 URL:http://192.168.254.100/ecshop/goods.php?id=3 现在需要实现把以 ...

  8. nginx url重写 rewrite实例

    本文介绍下,在nginx中实现Url重写,学习rewrite的具体用法,有需要的朋友参考下吧. 原文地址:http://www.360doc.com/content/14/0202/20/142341 ...

  9. A Script Pro nginx URL重写规则无法播放MP4解决方法

    I am using nginx and I have already add the line location /file/ { rewrite ^/-]+)/([-]+)/([^/]*)/([- ...

  10. nginx URL重写

    html { font-family: sans-serif } body { margin: 0 } article,aside,details,figcaption,figure,footer,h ...

随机推荐

  1. Ubuntu 13.10 解决虚拟机摄像头无法使用问题

    前段时间使用的是Ubuntu 13.04,使用virtualbox虚拟机 4.2版,虚拟机里边装的Windows 7和Windows8.1均无法使用摄像头.只要在USB设备中选上了摄像头,虚拟机系统准 ...

  2. 译:2. RabbitMQ Java Client 之 Work Queues (工作队列)

    在上篇揭开RabbitMQ的神秘面纱一文中,我们编写了程序来发送和接收来自命名队列的消息. 本篇我们将创建一个工作队列,工作队列背后的假设是每个任务都交付给一个工作者 本篇是译文,英文原文请移步:ht ...

  3. MySql实现sequence功能的代码

    使用函数创建自增序列管理表(批量使用自增表,设置初始值,自增幅度) 第一步:创建Sequence管理表 sequence DROP TABLE IF EXISTS sequence; CREATE T ...

  4. 学习MongoDB(Troubleshoot Replica Sets) 集群排除故障

    Test Connections Between all Members(集群中节点网络测试) 在进行Mongodb集群时,每个节点的网络都需要互动,假设有3个服务器节点. m1.example.ne ...

  5. PwniumCTF2014 - JJSN总结

    Write-ups 本文最早发布在TSRC,详细地址:http://security.tencent.com/index.php/blog/msg/55 Forensics USB is FUN 这道 ...

  6. headfirst python 03, 04

    文件与异常 python中的输入机制是基于行的, open()函数与for 语句结合使用, 可以非常容易的读取文件.(打开->处理->关闭) #!/usr/bin/env python # ...

  7. unable to locate package gparted

    在unbuntu安装gparted的时候出现这个错误提示,意思为:找不到这个安装包 可能的原因: 1.当前系统更新包没有更新,执行命令:sudo apt-get update 2.命令错误,重新检查需 ...

  8. Android GIS +webservice

    Android新手经典入门教程 Android开发教程(完全免费版) Android SDK v3.1.0 Android定位功能(一) Android定位功能(二) Android 百度地图开发(一 ...

  9. Android wpa_supplicant 四次握手 流程分析

    记录wpa_supplicant四次握手的过程. 相关log:https://www.cnblogs.com/helloworldtoyou/p/9633603.html 接收到第一次握手,会设置一个 ...

  10. MyCAT简易入门 (Linux)

    MyCAT是mysql中间件,前身是阿里大名鼎鼎的Cobar,Cobar在开源了一段时间后,不了了之.于是MyCAT扛起了这面大旗,在大数据时代,其重要性愈发彰显.这篇文章主要是MyCAT的入门部署. ...