Spring boot が ssl 利用してない場合、nginxの設定ファイルを以下のようにすればよいです。
nginx.conf
http {
upstream server_com {
server 127.0.0.1:8081;
}
server {
listen 80;
listen [::]:80;
server_name localhost;
location / {
proxy_http_version 1.1;
proxy_pass http://server_com;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header Access-Control-Allow-Origin *;
proxy_read_timeout 900;
}
}
}
spring boot が ssl を利用する場合、
nginx.conf
http {
server {
listen 80;
listen [::]:80;
server_name localhost;
#return 301 https://$host:4433$request_uri;
}
upstream server_com {
server 127.0.0.1:8443;
}
# HTTPS server
server {
listen 4433 ssl;
listen [::]:4433 ssl;
server_name localhost;
ssl_certificate /path/to/cert.pem;
ssl_certificate_key path/to/cert.key;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_pass https://server_com;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header Access-Control-Allow-Origin *;
proxy_read_timeout 900;
}
}
}