×ðÁú¿­Ê±

Nginx·´ÏòÊðÀíHTTPSÉèÖà £¬°ü¹ÜÍøÕ¾Êý¾Ý´«ÊäÇå¾²

nginx·´ÏòÊðÀíhttpsÉèÖà £¬°ü¹ÜÍøÕ¾Êý¾Ý´«ÊäÇå¾²

Ëæ×Å»¥ÁªÍøµÄ¿ìËÙÉú³¤ £¬ÍøÂçÇå¾²ÎÊÌâ±äµÃÔ½À´Ô½Ö÷Òª¡£ÔÚ´«ÊäÃô¸ÐÊý¾ÝµÄÍøÕ¾ÖÐ £¬Ê¹ÓÃHTTPSЭÒéÀ´¼ÓÃܺͱ£»¤Êý¾ÝµÄÇå¾²ÊDZز»¿ÉÉٵġ£Nginx×÷Ϊһ¿î¸ßÐÔÄܵÄWebЧÀÍÆ÷ºÍ·´ÏòÊðÀíЧÀÍÆ÷ £¬¿ÉÒÔͨ¹ýÉèÖÃʵÏÖHTTPSµÄ·´ÏòÊðÀí £¬½øÒ»²½°ü¹ÜÍøÕ¾Êý¾Ý´«ÊäµÄÇå¾²¡£±¾ÎĽ«ÏÈÈÝÔõÑùÔÚNginxÖÐÉèÖÃHTTPS·´ÏòÊðÀí £¬²¢ÌṩÏà¹ØµÄ´úÂëʾÀý¡£

Ê×ÏÈ £¬ÐèҪȷ±£ÒѾ­×¼È·×°ÖÃÁËNginx £¬²¢Í¨¹ýÔËÐÐnginx -vÏÂÁîÈ·ÈÏ°æ±¾ºÅ¡£½ÓÏÂÀ´ £¬ÎÒÃǽ«ÉèÖÃNginxÖ§³ÖHTTPS·´ÏòÊðÀí¡£

ÌìÉúSSLÖ¤Êé

Ê×ÏÈ £¬ÎÒÃÇÐèÒªÌìÉúSSLÖ¤Êé £¬ÒÔÈ·±£Êý¾ÝÔÚ´«ÊäÀú³ÌÖеÄÇå¾²ÐÔ¡  £¿ÉÒÔʹÓÃÃâ·ÑµÄLet’s EncryptÖ¤Êé £¬Ò²¿ÉÒÔ¹ºÖÃÉÌÒµSSLÖ¤Êé¡£

¼ÙÉèÎÒÃÇÑ¡ÔñʹÓÃLet’s EncryptÖ¤Êé £¬ÔÚЧÀÍÆ÷ÉÏ×°ÖÃcertbot¹¤¾ß £¬²¢ÔËÐÐÒÔÏÂÏÂÁîÒÔÌìÉúÖ¤Ê飺

sudo apt-get update
sudo apt-get install certbot
sudo certbot certonly --nginx

µÇ¼ºó¸´ÖÆ

ƾ֤ÌáÐÑÊäÈëÓòÃû £¬²¢Ñ¡Ôñ×Ô¶¯ÉèÖÃNginxÒÔʹÆäÖ§³ÖHTTPS¡£

ÉèÖÃNginx

ÌìÉúÖ¤Êéºó £¬ÎÒÃÇÐèÒªÉèÖÃNginxÒÔÖ§³ÖHTTPS·´ÏòÊðÀí¡£·­¿ªNginxµÄÉèÖÃÎļþ/etc/nginx/nginx.conf £¬²¢Ìí¼ÓÒÔÏÂÄÚÈÝ£º

http {
    server {
        listen 80;
        server_name example.com;
        return 301 https://$host$request_uri;
    }

    server {
        listen 443 ssl;
        server_name example.com;

        ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
        ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

        location / {
            proxy_pass http://backend-server;
            proxy_set_header Host $host;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        }
    }
}

µÇ¼ºó¸´ÖÆ

ÔÚÉÏÊöÉèÖÃÖÐ £¬ÎÒÃÇÊ×ÏÈÉèÖÃÁ˼àÌý80¶Ë¿ÚµÄserver¿é £¬½«ËùÓÐHTTPÇëÇóÖض¨ÏòÖÁHTTPS¡£È»ºó £¬ÉèÖÃÁ˼àÌý443¶Ë¿ÚµÄserver¿é £¬Ö¸¶¨SSLÖ¤ÊéµÄ·¾¶ £¬²¢ÉèÖÃÁË·´ÏòÊðÀíλÖÃ/ £¬½«ÇëÇóת·¢ÖÁºó¶ËЧÀÍÆ÷backend-server¡£

ÐèҪעÖصÄÊÇ £¬example.comÓ¦¸ÃÌ滻ΪÏÖʵµÄÓòÃû £¬backend-serverÓ¦¸ÃÌ滻ΪÏÖʵµÄºó¶ËЧÀÍÆ÷µØµã¡£

ÖØÆôNginxЧÀÍ

Íê³ÉÉèÖúó £¬ÉúÑÄÎļþ²¢ÖØÆôNginxЧÀÍÒÔʹÉèÖÃÉúЧ¡£ÔËÐÐÒÔÏÂÏÂÁ

sudo service nginx restart

µÇ¼ºó¸´ÖÆ

ÑéÖ¤HTTPS·´ÏòÊðÀí

ÏÖÔÚ £¬ÎÒÃÇ¿ÉÒÔͨ¹ý»á¼ûhttps://example.comÀ´ÑéÖ¤HTTPS·´ÏòÊðÀíµÄÉèÖá£ÈôÊÇÒ»ÇÐ˳Ëì £¬Äú½«¿´µ½Í¨¹ý·´ÏòÊðÀíת·¢µÄÄÚÈÝ £¬²¢ÇÒä¯ÀÀÆ÷µÄµØµãÀ¸½«ÏÔʾÇå¾²ÅþÁ¬µÄ±êʶ¡£

×ܽá

ͨ¹ýNginx·´ÏòÊðÀíµÄÉèÖà £¬ÎÒÃÇ¿ÉÒÔʵÏÖHTTPSЭÒéµÄÇå¾²Êý¾Ý´«Êä £¬½øÒ»²½°ü¹ÜÍøÕ¾Êý¾ÝµÄÇå¾²ÐÔ¡£ÔÚ±¾ÎÄÖÐ £¬ÎÒÃÇÏÈÈÝÁËÔõÑùÉèÖÃNginxÖ§³ÖHTTPS·´ÏòÊðÀí £¬²¢ÌṩÁËÏà¹ØµÄ´úÂëʾÀý¡£Í¨¹ýÕâÖÖ·½·¨ £¬ÎÒÃÇ¿ÉÒÔÈ·±£ÍøÕ¾ÔÚÊý¾Ý´«ÊäÀú³ÌÖеÄÇå¾²ÐÔ £¬²¢±ÜÃâÃô¸ÐÊý¾Ý±»ÇÔÈ¡»ò¸Ä¶¯¡£

ÒÔÉϾÍÊÇNginx·´ÏòÊðÀíHTTPSÉèÖà £¬°ü¹ÜÍøÕ¾Êý¾Ý´«ÊäÇå¾²µÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±ÊµÊ±ÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
¡¾ÍøÕ¾µØͼ¡¿¡¾sitemap¡¿