windows 아래 nginx 에서 OpenSSL 자체 서명 인증 서 를 설정 합 니 다.
5515 단어 nginx
nginx:1.16.1
git 설치
windos 에서 git 도 구 를 설치 한 후 openssl 도 구 를 가 져 갈 수 있 습 니 다.
인증서 생 성 신청 파일 과 비밀 키 파일
openssl req -nodes -newkey rsa:1024 -out myreq.pem -keyout privatekey.pem
# req:request ,
# -nodes: pin ,
# -newkey: , 2048
# -out: ,
# -keyout:
인증서 생 성
신청 파일 과 비밀 키 를 사용 하여 인증 서 를 신청 하고 자신 에 게 인증 서 를 발급 합 니 다.
openssl req -in myreq.pem -x509 -key privatekey.pem -out mycert.pem -days 365
# -in:
# -x509:
# -key:
# -out:
# -days:
설정 nginx
위 에서 생 성 된 파일 을
nginx/conf/cert
디 렉 터 리 에 놓 고 디 렉 터 리 구조:└─conf
│ nginx.conf
└─cert
mycert.pem
myreq.pem
privatekey.pem
openssl https.sh
전체 nginx 프로필 은 다음 과 같 습 니 다:
#user nobody;
worker_processes 1;
#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;
#
upstream backend_server{
# 1
server 127.0.0.1:8080 weight=1 max_fails=2 fail_timeout=5s;
keepalive 100;
}
server {
listen 80;
server_name 192.168.1.2;
# http https
rewrite ^(.*)$ https://$host$1 permanent;
#rewrite ^/(.*) https://$server_name$request_uri redirect;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
root html;
index index.html index.htm;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
# HTTPS server
#
server {
listen 443 ssl;
server_name 192.168.1.2;
keepalive_timeout 70;
ssl_certificate cert/mycert.pem;
ssl_certificate_key cert/privatekey.pem;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
#
location = / {
rewrite ^(.*)$ http://$host/server/ redirect;
#root html;
#index index.html index.htm;
}
#
location /server/{
proxy_connect_timeout 5s;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_pass http://backend_server;
}
location /status{
stub_status on;
}
}
# include vhost/*.conf;
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
간단! Certbot을 사용하여 웹 사이트를 SSL(HTTPS)화하는 방법초보자가 인프라 주위를 정돈하는 것은 매우 어렵습니다. 이번은 사이트를 간단하게 SSL화(HTTP에서 HTTPS통신)로 변경하는 방법을 소개합니다! 이번에는 소프트웨어 시스템 Nginx CentOS7 의 환경에서 S...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.