
本文共 2628 字,大约阅读时间需要 8 分钟。
Nginx��� HTTPS ��������� http ��� https ���������
��������� Nginx ������������ ������ ��������� HTTPS��������������������� ������ ������ http ������ ��� ������ ��������������������� Nginx ��� ������ ��������� http ��� https ��� ��� ��� ������������ ��� ������ ��� ������ ������ ��� ���������������
1. ������ Nginx ������
������ Nginx ������ ������ ��������������� Unix/Linux ������ ������ ������������������ /etc/nginx/sites-enabled/
��� ������ ������ ��������������� server ������������ ������ listener ��������������������� http port���80��� ������ ��� SSL/TLS port���443������
server { listen 443 ssl; # ������ 80 ��� 443 ssl on; ssl_certificate /path/to/cert.pem; # ������ SSL ������ ������ ������ ssl_key_file /path/to/server.key; # ������������ ������ ssl_protocols TLSv1.2 TLSv1.3; # ������������������ ��� ������ ��� SSL/TLS ������ ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256; # ��������������������� ������ add_header X-Frame-Options "DENY"; # ������ ��� XSS ������ add_header X-Content-Type-Options "nosniff"; # ������ ��������� ������}
2. HTTP ��� HTTPS ���������
������ ������ http ��� https ��� ��� ������������ ������������ navbar ������ ���������errorCodeMiddleware ���������� ���������
location / { return 301 https://$server_name$request_uri;}
������������ ��� ������ ��������� return ������������������
server { listen 80; # ��������������� http port server_name example.com; access_log off;}server { listen 443 ssl; server_name example.com; ssl on; ssl_certificate /path/to/cert.pem; ssl_key_file /path/to/server.key; location / { return 301 https://$server_name$request_uri; }}
3. ���������������
������ ������ https ��� ������ ������������ ��������������� ������������ ������ ��� ��������� HTTPS ��� ���������
firewall-cmd --zone=public --add-port=443/tcp
4. ������
- ������ ������ ������ ������������������ ������ ��� ������ ������ ��� HTTPS���
- ������ curl ������ ���������
curl -I http://example.com
������ ������ ������ ������ 301 Moving Permanently������������ ��� ������ ��� ��� ��� ��� ��� HTTPS���
��������������� ������ ��������� ������ ������ ������ ������������������ ��������� ��� ������ ��������������� ������ ��� ������ ��� ������ ��������� ������ ��������������� ������ ��������� ��� TLS ���������
��������������������������� ������ http ������ ������ ������ ������������ ������ ��������� ��� ��� ��� ��� HTTPS ���������
��������� ��� ��������� ������ ������ ��������������� ��� ������ ��� ��������bicalse lettuce ������ ��� ������
发表评论
最新留言
关于作者
