nginx配置https访问
1、配置文件内容如下:
worker_processes 1;
events {
worker_connections 1024;
}
error_log /tmp/error.log info;
http
{
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for';
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
server {
listen 8081 ssl;
ssl_certificate /etc/nginx/server.crt;
ssl_certificate_key /etc/nginx/server.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 / {
root /usr/local/web;
index index.html index.htm;
try_files $uri $uri/ /index.html;
}
location /server {
proxy_pass http://10.43.51.225:8082;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Proxy-Client-IP $remote_addr;
}
}
}