NGINX配置Https [英] NGINX Configure Https
问题描述
我正在尝试在http和https上运行我的应用程序.该应用程序呈现静态html及其css和js.我使用nginx服务页面.我已经配置了nginx配置,但是页面无法在https上呈现.
I am trying to run my application on http and https. The application renders static htmls along with their css' and js'. I use nginx to serve the pages. I have configured my nginx configuration, but the pages do not get rendered on https.
当我点击 http://subdomain.example.com 时,效果很好!
When I hit http://subdomain.example.com, it works well!
但是,当我点击 https://subdomain.example.com 时,我得到了CONNECTION_RESET或CONNECTION_CLOSEDChrome中的错误.
However, when I hit https://subdomain.example.com, I get a CONNECTION_RESET or a CONNECTION_CLOSED error in Chrome.
以下是我的配置:
server {
listen 80;
server_name subdomain.example.com;
#charset koi8-r;
#access_log /var/log/nginx/log/host.access.log main;
location / {
root /var/www/html/htmls/;
index entergmat.html;
}
}
server{
listen 443 ssl;
ssl on;
server_name subdomain.example.com;
ssl_certificate /path/to/certificate.crt;
ssl_certificate_key /path/to/certificate.key;
# ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# ssl_ciphers HIGH:!aNULL:!MD5;
keepalive_timeout 70;
location / {
root /var/www/html/htmls/;
index entergmat.html;
}
}
请求您的帮助.
谢谢!
推荐答案
我建议从您的配置中删除 ssl on;
:
I would suggest to remove ssl on;
from your configuration:
建议使用listen指令的ssl参数而不是此指令.
It is recommended to use the ssl parameter of the listen directive instead of this directive.
来自nginx文档 http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl
这篇关于NGINX配置Https的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!