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; 可以把不同的站点配置文件分开,方便管理

nginx配置指南

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开发框架网发布内容,转载请附上原文出处连接
张国生
上一篇:nginx websocket支持
下一篇:nginx配置http自动重定向到https
评论列表

发表评论

评论内容
昵称:
关联文章

nginx配置指南
nginx端口转发配置
nginx初始配置优化
windows Nginx配置开机自启动
C#爬虫:使用Selenium,Selenium配置指南
gitblit服务器配置指南
nginx配置http自动重定向到https
Nginx部署
CentOS安装nginx
.net Core项目.csproj配置指南
SEO刷排名工具参数配置指南
windows下openssl安装,证书生成,nginx配置https以及http重定向https
Python使用selenium+chrome配置指南
nginx websocket支持
nginx反向代理https
宝塔系统 nginx位置记录
bing必应网站站长指南
CentOS7 nginx SSL证书申请并自动续期
nginx集群中按照url规则指定节点访问
nginx安装为windows服务

联系我们
联系电话:15090125178(微信同号)
电子邮箱:garson_zhang@163.com
站长微信二维码
微信二维码