search

Home  >  Q&A  >  body text

How to configure ssl in nginx to allow both http and https access

Now after configuration, accessing http will automatically jump to https- -. It hurts so much

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;
}
仅有的幸福仅有的幸福2791 days ago614

reply all(4)I'll reply

  • ringa_lee

    ringa_lee2017-05-16 17:30:38

    This is in the Nginx documentation:

    listen              80;
    listen              443 ssl;
    

    Reference: http://nginx.org/en/docs/http/configuring_https_servers.html

    reply
    0
  • 天蓬老师

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

    Is it possible to use two servers?

    reply
    0
  • 世界只因有你

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

    Isn’t this the poster’s configuration? You should need two servers, one listening on port 80 and the other listening on port 443. Jiang Zi...

    reply
    0
  • 淡淡烟草味

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

    ssl on; Just remove this line

    reply
    0
  • Cancelreply