欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

nginx 配置

程序员文章站 2022-06-11 22:38:17
...
upstream www.bugyun.com {
  			# 后台服务器地址
       server 10.47.88.131:8080;
  }

# 配置虚拟机
server{
	
	 # 配置监听端口
   listen 80;
   #	配置访问域名
   server_name www.bugyun.com;
   # 对以html|htm等结尾的地址进行负载均衡
   location ~ .*\.(html|htm|gif|jpg|jpeg|bmp|png|ico|txt|js|css|ttf|woff|woff2|svg|eot)$ {
       root /usr/local/nginx/bugyun-web;
       index  index.html;
  
      add_header Access-Control-Allow-Origin *;
 		  add_header Access-Control-Allow-Headers X-Requested-With;  
			add_header Access-Control-Allow-Methods GET,POST,OPTIONS;
   }
   # 所有以/开头的地址,实际上是所有请求
	location / {
		# 去请求Linux下/usr/local/nginx/bugyun-web文件夹里的文件
		root /usr/local/nginx/bugyun-web;
		# 首页响应地址
    index  index.html;
	}
    location /api-schedule {
    
    	 # 设置被代理服务器的端口或套接字,以及URL
       proxy_pass         http://www.bugyun.com;
       
       # 将代理服务器收到的用户的信息传到真实服务器上
       proxy_set_header   Host             $host;
       proxy_set_header   X-Real-IP        $remote_addr;
       proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
       
       # 设定通过nginx上传文件的大小
       client_max_body_size 8000M;
       
       add_header Access-Control-Allow-Origin *;
			 add_header Access-Control-Allow-Headers X-Requested-With;  
			 add_header Access-Control-Allow-Methods GET,POST,OPTIONS;

   }

	location /api-wechat {
       proxy_pass         http://www.bugyun.com;
       proxy_set_header   Host             $host;
       proxy_set_header   X-Real-IP        $remote_addr;
       proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
       client_max_body_size 8000M;
   }