40 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			40 lines
		
	
	
		
			1.2 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| upstream agent_backend {
 | |
|     server 172.24.16.10:8070  weight=10 max_fails=3 fail_timeout=30s;
 | |
|     server 172.24.16.7:8070   weight=10 max_fails=3 fail_timeout=30s;
 | |
|     keepalive 300;
 | |
| }
 | |
| 
 | |
| server {
 | |
|     listen 80;
 | |
|     server_name _;
 | |
| 
 | |
|     access_log /data/tengine/logs/agent_log/agent_access.log;
 | |
|     error_log /data/tengine/logs/agent_log/agent_error.log;
 | |
| 
 | |
|     location / {
 | |
|         proxy_pass http://agent_backend;
 | |
|         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_set_header X-Forwarded-Proto $scheme;
 | |
| 
 | |
|         # 可选:保持长连接
 | |
|         proxy_http_version 1.1;
 | |
|         proxy_set_header Connection "";
 | |
| 
 | |
|         # 允许跨域
 | |
|         add_header 'Access-Control-Allow-Origin' "$http_origin" always;
 | |
|         add_header 'Access-Control-Allow-Credentials' 'true' always;
 | |
|         add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, DELETE' always;
 | |
|         add_header 'Access-Control-Allow-Headers' 'Authorization,Content-Type,X-Requested-With,Accept,Origin' always;
 | |
|         # 处理预检请求
 | |
|         if ($request_method = OPTIONS ) {
 | |
|             return 204;
 | |
|         }
 | |
|     }
 | |
| }
 | |
| 
 | |
| 
 | |
| 机器A的
 | |
| 
 |