文章介绍nginx如何配置https并配置代理java接口
1、将密码的.pem文件转为.key文件
openssl rsa -in privkey.pem -out privkey.key
2、nginx的配置文件
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 80;
gzip on;
gzip_min_length 1k;
gzip_comp_level 9;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
server_name localhost;
location / {
root "D:\snowy\dist";
try_files $uri $uri/ @router;
index index.html index.htm;
error_page 405 =200 http://$host$request_uri;
}
location /api/ {
proxy_pass http://localhost:9003/api/;
proxy_connect_timeout 6000;
proxy_read_timeout 6000;
}
location @router {
rewrite ^.*$ /index.html last;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
server {
listen 443 ssl;
gzip on;
gzip_min_length 1k;
gzip_comp_level 9;
gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
server_name *****.com;
ssl_certificate D:\\nginx-1.21.6\\wx.js-whzl.com\\cert.pem;
ssl_certificate_key D:\\nginx-1.21.6\\wx.js-whzl.com\\privkey.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers ALL:!DH:!EXPORT:!RC4:+HIGH:+MEDIUM:!LOW:!aNULL:!eNULL;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_prefer_server_ciphers on;
location / {
root "D:\snowy\dist_test\dist";
try_files $uri $uri/ @router;
index index.html index.htm;
}
location /api/ {
proxy_pass http://localhost:9003/api/;
proxy_connect_timeout 6000;
proxy_read_timeout 6000;
}
}
}
|