server {
listen 80;
# 改为你的域名
server_name
xxxx.com;
return 301 https://$host$request_uri;
}
upstream app_proxy {
# 后端网关地址
# least_conn;
# 这里转发到你的服务器上
server 172.19.1.23:8001 max_fails=10 fail_timeout=10s;
keepalive 16;
}
server {
listen 443;
# 改为你的域名
server_name
xxxx.com;
# 1.5 版本后有警告
ssl on;
# 证书申请后请放在 /etc/nginx/ssl 对应的站点下(docker 中的路径)
ssl_certificate /etc/nginx/ssl/
xxxx.com/fullchain.cer; ssl_certificate_key /etc/nginx/ssl/
xxxx.com/xxxx.com.key; ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
server_tokens off;
sendfile on;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_comp_level 2;
gzip_types text/plain application/x-javascript application/javascript text/css;
gzip_vary on;
gzip_disable "MSIE [1-6]\.";
client_max_body_size 10m;
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
set $Real $http_x_forwarded_for;
if ( $Real ~ (\d+)\.(\d+)\.(\d+)\.(\d+),(.*) ){
set $Real $1.$2.$3.$4;
}
proxy_set_header X-Real-Ip $Real;
proxy_pass http://app_proxy;
}
}
nginx 的配置,转发到你的服务器上,不了解 Sprintboot 什么的,希望对你有用。
上面的意思是: http 会跳转到 https,nginx 会转发到 app_proxy 对应的服务器上。