Nginx 구성 SSL 인증서

Nginx 구성 SSL 인증서

여기에 이미지 설명 삽입
인증서를 구성하기 전에 이러한 준비를 수행하여 Nginx , ssl 모듈, 도메인 이름 확인 및 인증서 파일을 설치해야 합니다.

  1. conf 디렉토리에 ssl(인증서 파일 저장), vhost(구성 저장) 폴더를 만들고 ngxin.conf의 http 모듈에 삽입합니다.포함 vhost/*.conf;(vhost 폴더 아래의 구성 파일에 도입됨)
    여기에 이미지 설명 삽입
  2. 다운로드한 인증서 파일을 ssl 디렉토리에 압축 해제 현재 파일은 .pem, .key 2개뿐이며,
    여기에 이미지 설명 삽입
    다음 명령어를 순차적으로 실행하여 .cer, .crt 파일을 생성합니다. 여기에 있는 xxx를 자신의 파일 이름으로 바꾸십시오.
  • openssl pkcs12 -export -out cacert.p12 -in ./xxx.pem -inkey ./xxx.key
  • 서버 비밀번호를 두 번 입력하십시오
  • openssl pkcs12 -in cacert.p12 -out xxx.crt -nokeys -clcerts
  • 서버 암호를 한 번 입력하십시오
  • openssl x509 -inform pem -in xxx.crt -outform der -out xxx.cer
    여기에 이미지 설명 삽입
  1. vhost 폴더에 새 xxx.conf를 생성합니다. 자세한 구성은 다음과 같습니다.
	# 开启SSL
	server {
	# 监听 443 端口
	listen 443 ssl;
	
	# 指定SSL 可访问的网站
	server_name test.com;
	# 指定crt文件路径
	ssl_certificate /usr/local/nginx/conf/ssl/crm.eyunzhirong.com/xxx.crt;
	# 指定key文件路径
	ssl_certificate_key /usr/local/nginx/conf/ssl/crm.eyunzhirong.com/xxx.key;
	
	location / {
	proxy_set_header X-Real-IP $remote_addr;
	proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
	proxy_set_header Host $http_host;
	proxy_set_header X-NginX-Proxy true;
	
	# 指定 SSL 指向本地端口
	proxy_pass http://127.0.0.1:18180/;
	
	proxy_redirect off;
	
	# Socket.IO Support
	proxy_http_version 1.1;
	proxy_set_header Upgrade $http_upgrade;
	proxy_set_header Connection "upgrade";
	    }
	}
  1. 구성이 완료되었습니다. nginx를 다시 시작하십시오.
  • nginx 일반 명령:
  • 빠른 중지: nginx -s stop
  • 순서대로 중지 완료: nginx -s quit
  • 재시작: nginx -s reload
  • nginx 서비스 시작: service nginx start
  • 구성 파일 다시 로드: nginx -s reload
  1. 소규모 프로그램 개발일 경우 보안을 위해 도메인네임 확인 필요

주소 확인: https://ssltools.digicert.com/checker/views/checkInstallation.jsp
여기에 이미지 설명 삽입

중간 인증서가 없는 경우 PC 측에서는 WeChat 애플릿이 정상적으로 표시되지만 모바일 측에서는 "request:fail -2:net::ERR_FAILED" 오류를 보고합니다 . 해결 방법은 다음과 같습니다.


좋은 것의 법칙: 모든 것은 결국 좋은 것이 될 것이고, 좋은 것이 아니라면 아직 끝이 아니라는 뜻입니다.

추천

출처blog.csdn.net/Cike___/article/details/122060813