위 챗 애플 릿 https 와 ws, nginx 에이전트,
최근 위 챗 애플 릿 에 관 한 웹 소켓 을 접 했 습 니 다. 애플 릿 백 엔 드 서비스 에 필요 한 https 설정 과 ws 설정 은 테스트 를 통 해 애플 릿 백 엔 드 서비스 배 치 를 실현 하 였 습 니 다.위 챗 애플 릿, SpringBoot 를 배경 으로 nginx 설정 을 사용 하여 https 설정 과 ws 설정 방안 을 해결 합 니 다.
계획
아 리 무료 CA 인증서, nginx 에이전트 전송 요청, netty 웹 소켓 서버 구축 및 심장 박동 유지
아 리 증 서 는 소개 하지 않 겠 습 니 다. 간단 합 니 다.
nginx 에이전트
애플 릿 은 https, ws (애플 릿 websocket 필요) 를 까다 롭 게 요구 합 니 다.
ws 는 사실 http 의 업그레이드 프로 토 콜 이기 때문에 하나의 포트 를 공유 할 수 있 습 니 다.
nginx 의 ngxin. conf 설정 사례 를 보 여 줍 니 다.
#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;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket {
server localhost:9999; # websocket
}
upstream web {
server localhost:8090; # web
}
server {
listen 443;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
ssl on;
ssl_certificate 214660810500.pem; # , nginx.conf
ssl_certificate_key 214660810500.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://web;
proxy_set_header X-real-ip $remote_addr;
proxy_set_header Host $http_host;
}
# websocket :wss://localhost/websocket
location /websocket {
proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
웹 서비스: tomcat 8090
웹 소켓 서비스: netty 9999
메모: nginx 1.3 이상 버 전에 서 웹 소켓 의 역방향 대 리 를 지원 합 니 다.
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 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에 따라 라이센스가 부여됩니다.