首页  >  问答  >  正文

nginx怎么配置ssl可以即允许http访问也允许https访问

现在配置好后访问http会自动跳转到https- -。好蛋疼

server {
    listen 80;
    listen 443;

    server_name *.domain.com;
    root /data0/web/domian.com;
    index index.php;

    ssl on; 
    ssl_certificate /data0/configs/domain.com.crt; 
    ssl_certificate_key /data0/configs/domain.com.pem;

    location / {
    }

    include php.conf;
}
仅有的幸福仅有的幸福2712 天前543

全部回复(4)我来回复

  • ringa_lee

    ringa_lee2017-05-16 17:30:38

    这个在Nginx的文档中有的:

    listen              80;
    listen              443 ssl;
    

    参考:http://nginx.org/en/docs/http/configuring_https_servers.html

    回复
    0
  • 天蓬老师

    天蓬老师2017-05-16 17:30:38

    两个server行不行?

    回复
    0
  • 世界只因有你

    世界只因有你2017-05-16 17:30:38

    楼主这么配置不行吧,应该要两个server,一个监听的是80端口,一个监听的是443端口。酱紫...

    回复
    0
  • 淡淡烟草味

    淡淡烟草味2017-05-16 17:30:38

    ssl on; 把这行去掉就好了

    回复
    0
  • 取消回复