nginx配置指南
修改nginx.conf配置文件内容为:
Markup 全选
worker_processes 1;
events {
worker_connections 1024;
}
http {
server_names_hash_bucket_size 128;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
include ../vhost/*.conf;
}
重点在 include ../vhost/*.conf; 可以把不同的站点配置文件分开,方便管理
vhost目录中数据如下:
vhost\test.jocsoft.com.conf
Markup 全选
server {
listen 80;
server_name test.jocsoft.com;
return 301 https://$host$request_uri; # HTTP请求自动重定向到HTTPS
}
server {
listen 443 ssl;
server_name test.jocsoft.com;
root E:\\webs\\test.jocsoft.com\\web\\pc;
index index.html;
ssl_certificate E:\\ssl\\nginx\\test.jocsoft.com_bundle.pem;
ssl_certificate_key E:\\ssl\\nginx\\test.jocsoft.com.key;
gzip on;
gzip_static on;
gzip_min_length 1k;
gzip_comp_level 4;
gzip_proxied any;
gzip_types text/plain text/xml text/css;
gzip_vary on;
gzip_http_version 1.0;
gzip_disable "MSIE [1-6]\.(?!.*SV1)";
# JNPF-START
# 设置上传文件的大小
client_max_body_size 100m;
# 添加头部信息
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-NginX-Proxy true;
# This is necessary to pass the correct IP to be hashed
real_ip_header X-Real-IP;
proxy_connect_timeout 300;
location / {
try_files $uri $uri/ /index.html;
}
# 后端服务
location /server/ {
proxy_read_timeout 2400; # 秒 20分钟 请求超时
proxy_pass http://localhost:5000/;
}
}
使用http访问会自动重定向跳转到https
版权声明:本文为YES开发框架网发布内容,转载请附上原文出处连接
post 张国生