apache 强制跳转HTTPS的问题解决

访问自己本地的网站,会出现强制跳转HTTPS的问题,首先看自己的代码,确定非代码问题, 非 SPRING 引起<intercept-url pattern="/**" requires-channel="https"/>,

非APACHE 配置443的原因。


经查是因为

HSTS(HTTP Strict Transport Security)国际互联网工程组织IETE正在推行一种新的Web安全协议
HSTS的作用是强制客户端(如浏览器)使用HTTPS与服务器创建连接。
那么需要去修改 APACHE 的配置文件 ,httpd.conf, 模块为 LoadModule headers_module modules/mod_headers.so 确认已开启


增加: Header set "Strict-Transport-Security" "maxage=0;includeSubDomains"




RequestHeader Directive

Description: Configure HTTP request headers
Syntax: RequestHeader set|append|merge|add|unset|edit header [value] [replacement] [early|env=[!]variable]
Context: server config, virtual host, directory, .htaccess
Override: FileInfo
Status: Extension
Module: mod_headers
Compatibility: The merge argument is available in version 2.2.9 and later. The edit argument is available in version 2.2.4 and later.

This directive can replace, merge, change or remove HTTP request headers. The header is modified just before the content handler is run, allowing incoming headers to be modified. The action it performs is determined by the first argument. This can be one of the following values:

set
The request header is set, replacing any previous header with this name
append
The request header is appended to any existing header of the same name. When a new value is merged onto an existing header it is separated from the existing header with a comma. This is the HTTP standard way of giving a header multiple values.
merge
The request header is appended to any existing header of the same name, unless the value to be appended already appears in the existing header's comma-delimited list of values. When a new value is merged onto an existing header it is separated from the existing header with a comma. This is the HTTP standard way of giving a header multiple values. Values are compared in a case sensitive manner, and after all format specifiers have been processed. Values in double quotes are considered different from otherwise identical unquoted values.  Available in version 2.2.9 and later.
add
The request header is added to the existing set of headers, even if this header already exists. This can result in two (or more) headers having the same name. This can lead to unforeseen consequences, and in general  setappend or  merge should be used instead.
unset
The request header of this name is removed, if it exists. If there are multiple headers of the same name, all will be removed.  value must be omitted.
edit
If this request header exists, its value is transformed according to a  regular expression search-and-replace. The  value argument is a  regular expression, and the replacement is a replacement string, which may contain backreferences.  Available in version 2.2.4 and later.

This argument is followed by a header name, which can include the final colon, but it is not required. Case is ignored. For setappendmerge and add a value is given as the third argument. If a value contains spaces, it should be surrounded by double quotes. For unset, no value should be given. value may be a character string, a string containing format specifiers or a combination of both. The supported format specifiers are the same as for the Header, please have a look there for details. Foredit both a value and a replacement are required, and are a regular expression and a replacement string respectively.

The RequestHeader directive may be followed by an additional argument, which may be used to specify conditions under which the action will be taken, or may be the keyword early to specify early processing. If the environment variable specified in the env=... argument exists (or if the environment variable does not exist andenv=!... is specified) then the action specified by the RequestHeader directive will take effect. Otherwise, the directive will have no effect on the request.

Except in early mode, the RequestHeader directive is processed just before the request is run by its handler in the fixup phase. This should allow headers generated by the browser, or by Apache input filters to be overridden or modified.


RequestHeader Directive

Description: Configure HTTP request headers
Syntax: RequestHeader set|append|merge|add|unset|edit header [value] [replacement] [early|env=[!]variable]
Context: server config, virtual host, directory, .htaccess
Override: FileInfo
Status: Extension
Module: mod_headers
Compatibility: The merge argument is available in version 2.2.9 and later. The edit argument is available in version 2.2.4 and later.

This directive can replace, merge, change or remove HTTP request headers. The header is modified just before the content handler is run, allowing incoming headers to be modified. The action it performs is determined by the first argument. This can be one of the following values:

set
The request header is set, replacing any previous header with this name
append
The request header is appended to any existing header of the same name. When a new value is merged onto an existing header it is separated from the existing header with a comma. This is the HTTP standard way of giving a header multiple values.
merge
The request header is appended to any existing header of the same name, unless the value to be appended already appears in the existing header's comma-delimited list of values. When a new value is merged onto an existing header it is separated from the existing header with a comma. This is the HTTP standard way of giving a header multiple values. Values are compared in a case sensitive manner, and after all format specifiers have been processed. Values in double quotes are considered different from otherwise identical unquoted values.  Available in version 2.2.9 and later.
add
The request header is added to the existing set of headers, even if this header already exists. This can result in two (or more) headers having the same name. This can lead to unforeseen consequences, and in general  setappend or  merge should be used instead.
unset
The request header of this name is removed, if it exists. If there are multiple headers of the same name, all will be removed.  value must be omitted.
edit
If this request header exists, its value is transformed according to a  regular expression search-and-replace. The  value argument is a  regular expression, and the replacement is a replacement string, which may contain backreferences.  Available in version 2.2.4 and later.

This argument is followed by a header name, which can include the final colon, but it is not required. Case is ignored. For setappendmerge and add a value is given as the third argument. If a value contains spaces, it should be surrounded by double quotes. For unset, no value should be given. value may be a character string, a string containing format specifiers or a combination of both. The supported format specifiers are the same as for the Header, please have a look there for details. Foredit both a value and a replacement are required, and are a regular expression and a replacement string respectively.

The RequestHeader directive may be followed by an additional argument, which may be used to specify conditions under which the action will be taken, or may be the keyword early to specify early processing. If the environment variable specified in the env=... argument exists (or if the environment variable does not exist andenv=!... is specified) then the action specified by the RequestHeader directive will take effect. Otherwise, the directive will have no effect on the request.

Except in early mode, the RequestHeader directive is processed just before the request is run by its handler in the fixup phase. This should allow headers generated by the browser, or by Apache input filters to be overridden or modified.

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值