Nginx实现前后端分离
#usernobody; worker_processes1; #error_loglogs/error.log; #error_loglogs/error.lognotice; #error_loglogs/error.loginfo; #pidlogs/nginx.pid; events{ worker_connections1024; } http{ includemime.types; default_typeapplication/octet-stream; #sendfileon; #tcp_nopushon; #keepalive_timeout0; keepalive_timeout65; proxy_set_headerCookie$http_cookie; proxy_set_headerX-Forwarded-Host$host; proxy_set_headerX-Forwarded-Server$host; proxy_set_headerX-Forwarded-For$proxy_add_x_forwarded_for; proxy_set_headerHost$host; proxy_set_headerX-Real-IP$remote_addr; gzipon; sendfileon; server{ listen8100; server_namelocalhost; location=/{ root/Users/abee/WebstormProjects/Angular/dist; indexindex.htmlindex.htm; try_files$uri$uri//index.html=404; } location~*\.(js|css|htm|html|gif|jpg|jpeg|png|bmp)${ root/Users/abee/WebstormProjects/Angular/dist; } location/{ proxy_passhttp://localhost:8200/; } } }
如果有多个server端location可使用另一种配置
location/server1/{ proxy_passhttp://localhost:8300/; }
以上就是本次给大家带来的关于Nginx实现前后端分离的全部内容,感谢你对毛票票的支持。