zoukankan      html  css  js  c++  java
  • nginx url问题

    测试需求,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.

  • 相关阅读:
    C#根据url生成唯一的key
    MyBatis基本配置和实践(四)
    MyBatis基本配置和实践(三)
    MyBatis基本配置和实践(二)
    MyBatis基本配置和实践(一)
    dbcp2、c3p0、druid连接池的简单配置
    HTTP长连接和短连接
    Java Web高性能开发
    三层构架 和 MVC 是什么?
    Docker bridge探索
  • 原文地址:https://www.cnblogs.com/zhengchunyuan/p/10032319.html
Copyright © 2011-2022 走看看