nginx根据http请求,将JSON的请求转发到后端,将非JSON请求,转发到前端

nginx.conf

worker_processes  1;
events { worker_connections
1024; }
http {
include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 22816; #server_name localhost; location / {   if ($http_accept ~* .*json.*) {     proxy_pass http://IP_1:8082;     break;   }   proxy_pass http://IP_2:8081; } } }

 

posted @ 2020-05-22 15:46  理舞  阅读(1115)  评论(0编辑  收藏  举报