55-nginx_conf_https, nginx configure https

Time:2022-11-12
#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;




    # HTTPS server
    #
    server {
        listen       443 ssl;
        server_name  ql.gaojilaochacang.com;

        ssl_certificate      /home/gpkey/gp.pem;
        ssl_certificate_key  /home/gpkey/gp.key;

        ssl_session_cache    shared:SSL:1m;
        ssl_session_timeout  5m;

        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers  on;

        location / {
            proxy_pass  http://127.0.0.1:8080;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-Proto https;
            proxy_http_version 1.1;
            # for websocket 
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
        }
    }
    
    server {
        listen 80;
        server_name ql.gaojilaochacang.com;
        #Convert the request to https
        rewrite ^(.*)$ https://$host$1 permanent;
    }

}

Recommended Today

Finally, “Graphic HTTP” reading notes – summary (summary)

Finally, “Graphic HTTP” reading notes – summary (summary) introduction I finished another book on the basics of the network. This book is recommended to be combined with [[“How the Network is Connected” Reading Notes-Summary]](https://segmentfault.com/a/11…) This reading note is edible (of course, you can also read the original book directly). After reading these two books, I […]