Nginx配置http和https共存
2018-03-20 23:15:00
915次阅读
0个评论
给nginx配置SSL证书之后,https可以正常访问,http访问显示400错误,nginx的配置如下:
server {
listen 80 default backlog=2048;
listen 443;
server_name xxx.com;
root /var/www/html;
ssl on;
ssl_certificate /usr/local/www/sslcrt/xxx.crt;
ssl_certificate_key /usr/local/www/sslcrt/xxx.key;
}
http访问的时候,报错如下:
400 Bad Request
The plain HTTP requset was sent to HTTPS port. Sorry for the inconvenience.
Please report this message and include the following information to us.
Thank you very much!
信息显示http的请求被发送到https的端口,所以才会出现这样的错误。
将ssl on;这行注释,ssl写在443端口后面。这样http和https的链接都可以用,完美解决。
server {
listen 80 default backlog=2048;
listen 443 ssl;
server_name linuxyan.com;
root /var/www/html;
ssl_certificate /usr/local/www/sslcrt/xxx.crt;
ssl_certificate_key /usr/local/www/sslcrt/xxx.key;
}
00
相关话题
- Nginx开启https负载均衡,配置Tomcat识别http和https协议
- Nginx配置WebSocket负载均衡
- Nginx端口转发端口配置
- Nginx配置Symantec 免费版 SSL证书
- HTTP Header中不能传输中文
- 使用Let's Encrypt通配符HTTPS证书
- Nginx根据User Agent动态配置root目录适配移动端
- TiDB 和 MySQL的差异
- CentOS设置时间和时区
- nginx禁止访问文件或目录的配置方法及location指令的uri匹配规则
- nginx 多组件安装及secure_link配置与文件下载防盗链的使用
- Nginx支持字体文件
- <p>标签和<pre>标签不能互相嵌套
- mysql mysqldump数据库和表导出语句
- SpringMvc实现RESTful风格的delete和put请求