Nginx代理https接口,附上Nginx配置文件,詳情見注釋。
server {
listen 443 ssl;
server_name api.xxx.com;
access_log /root/logs/index.access.log main;
error_log /root/logs/index.error.log;
root /;
index index.html index.htm index.php;
ssl_certificate cert/xxx.pem; #將domain name.pem替換成您證書的文件名。
ssl_certificate_key cert/xxx.key; #將domain name.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;
## send request back to apache ##
location / {
#Proxy Settings
# 接口的本地地址 反向代理
proxy_pass http://localhost:50005;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_max_temp_file_size 0;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}