VPS侦探论坛

 找回密码
 注册
查看: 8783|回复: 3

在ngixn下,如何设置https

[复制链接]
发表于 2010-4-5 17:42:31 | 显示全部楼层 |阅读模式

我在/usr/local/nginx/conf/nginx.conf文件的末尾添加了如下内容:
server {
    server_name mydomain.com;
    listen 443;
    index index.html index.htm index.php;
    root /home/wwwroot;
    ssl on;
    ssl_certificate /usr/local/nginx/conf/server.crt;
    ssl_certificate_key /usr/local/nginx/conf/server.key;
}

然后运行/usr/local/nginx/sbin/nginx -t以测试nginx.conf是否正确,显示:

[emerg]: unknown directive "server" in /usr/local/nginx/conf/nginx.conf:93
configuration file /usr/local/nginx/conf/nginx.conf test failed

上面unknown directive "server"是什么意思?难道在"{"的前面不该添加server这个字眼吗?
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2010-4-10 12:55:40 | 显示全部楼层

回复 1# 的帖子



不是添加在末尾,是添加在最后一个}的前面。
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
发表于 2010-5-27 18:51:47 | 显示全部楼层

不想用,也没有ssl证书,就是让他跑在443端口,中间随便加加密可以吗?
美国VPS推荐: 遨游主机LinodeLOCVPS主机云搬瓦工80VPSVultr美国VPS主机中国VPS推荐: 阿里云腾讯云。LNMP付费服务(代装/问题排查)QQ 503228080
发表于 2010-5-27 20:28:06 | 显示全部楼层



如果只想用443端口的话,可以去掉ssl添加的东西。如果用https访问就必须用ssl证书。
Linux下Nginx+MySQL+PHP自动安装工具:https://lnmp.org
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|Archiver|VPS侦探 ( 鲁ICP备16040043号-1 )

GMT+8, 2024-5-18 13:04 , Processed in 0.026295 second(s), 16 queries .

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表