Nginx 配置方案
server {
listen 80;
server_name www.yourname.com;
rewrite ^(.*)$ https://${server_name}$1 permanent;
}
server {
listen 443;
server_name www.yourname.com;
ssl on;
root html;
index index.html index.htm;
ssl_certificate /data/cert/yourname.pem;
ssl_certificate_key /data/cert/yourname.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;
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
#proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://127.0.0.1:8080/;
}
}
springboot YML配置
server:
port: 8080
use-forward-headers: true
tomcat:
remote_ip_header: x-forwarded-for
protocol_header: x-forwarded-proto
port-header: X-Forwarded-Port