强制http跳转https页面_https怎么改成http

2020-02-27 其他范文 下载本文

强制http跳转https页面由刀豆文库小编整理,希望给你工作、学习、生活带来方便,猜你可能喜欢“https怎么改成http”。

she强制http跳转https页面

简介

https在现在网络中是公认的安全的访问方式,但是在访问的过程中很多站点是没有强制https访问的,这样会导致有些客户可以通过http访问,从而对服务器造成一些不安全因素。下文将介绍几种强制https访问的方法。

一,wordpre中设置https强制访问。

默认登录wordpre的后台是使用http协议,这协议是明文发送的。这可能会导致你的用户和密码被窃听。如果使用l登录,这种情况则可以避免。下面是设置方法。

1、设置wp-config.php /* That's all, stop editing!Happy blogging.*/...require_once(ABSPATH.'wp-settings.php');

2、在上面的代码之前加上如下代码:

define('FORCE_SSL_LOGIN', true);define('FORCE_SSL_ADMIN', true);define(‘FORCE_SSL_LOGIN’, true);

#是启用登录时使用l define(‘FORCE_SSL_ADMIN’, true);#后台管理也使用l

如果担心后台使用l影响速度,可以不用。但还是建议使用,因为这将有可能cookie被劫持导致黑客伪造cookie登录后台。

wordpre只需要几步设定就可以启用强制使用HTTPS登入后端管理界面

首先到wp-config.php中找到下面这段: if(!defined(‘ABSPATH’))

define(‘ABSPATH’, dirname(__FILE__).‘/’);

找到它以后,請在它上面加入下列此行: define(‘FORCE_SSL_LOGIN’, true);

接下來请在VHOST上设定好SSL的相关设置..这里就不再叙述了

以下附上nginx上如何使用vhost并且自动rewrite url跳转到https管理页面的设定值: 请在rewrite rule上面加入rewrite ^.*/wp-admin(.*)

https://wp.littlecho.tw/wp-admin$1 last;即可

例如下: location / { try_files $uri $uri/ /index.php;rewrite ^.*/wp-admin(.*)https://wp.littlecho.tw/wp-admin$1 last;} 设定完毕后当输入http://xxxx.domain.tld/wp-admin时就会自动跳转了。

二,tomcat中的跳转配置

在tomcat中设置强制https的方法有2种,下面分别介绍下这2种方法的配置:

1,调整web.xml文件,将HTTP使用的server.xml文件重定向端口

在记事本中打开 SGMS4TomcatwebappssgmsWEB-INFweb.xml文件,在web.xml的文件末尾的前一句添加以下内容:

404

/error_404.jsp

Tomcat

/*

CONFIDENTIAL

2,调整server.xml文件以便重定向端口443。这样做你需要更改server.xml文件,在记事本中打开 SGMS4Tomcatconfserver.xml文件,重定向443端口:

重启服务,这个时候就会实现访问HTTP时,使用HTTPS安全协议了。

三,在JSP代码的页面中的配置

jsp代码:

String scheme=request.getScheme();String url=request.getRequestURI();if(!“HTTPS”.equalsIgnoreCase(scheme)){

response.sendRedirect("https://|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|c)$ {

root html;

expires

1h;

}

location /CwlProApi {

rewrite ^/(.*)https://192.168.17.11:8443/$1 permanent;

}# 同 web一样 } server {

listen

443;

server_name localhost;

l

on;

l_certificate

/opt/embrace-nginx/nginx/conf/server.pem;

l_certificate_key /opt/embrace-nginx/nginx/conf/server.key;

l_seion_timeout 5m;

l_protocols

SSLv3 TLSv1;

l_ciphers

ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;

l_prefer_server_ciphers

on;

location /CwlProWeb {

proxy_pa http://cwlproweb;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

}#配置下转发规则

location ~.*.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|c)$ {

root html;

expires

1h;

} } server {

listen

8443;

server_name localhost;

l

on;

l_certificate

/opt/embrace-nginx/nginx/conf/server.pem;

l_certificate_key /opt/embrace-nginx/nginx/conf/server.key;

l_client_certificate /opt/embrace-nginx/nginx/conf/ca.crt;#客户端的根证书

l_verify_client

on;#开启双向认证模式

l_seion_timeout 5m;

l_protocols

SSLv3 TLSv1;

l_ciphers

ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;

l_prefer_server_ciphers

on;

location /CwlProApi {

proxy_pa http://cwlproapi;

proxy_set_header Host $host;

proxy_set_header X-Real-IP $remote_addr;

proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

} #同web一样的配置

}

《强制http跳转https页面.docx》
将本文的Word文档下载,方便收藏和打印
推荐度:
强制http跳转https页面
点击下载文档
相关专题 https怎么改成http 跳转 页面 http https怎么改成http 跳转 页面 http
[其他范文]相关推荐
    [其他范文]热门文章
      下载全文