Nginx实现前后端分离
程序员文章站
2022-09-25 22:59:28
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_l...
#user nobody; worker_processes 1; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; #sendfile on; #tcp_nopush on; #keepalive_timeout 0; keepalive_timeout 65; proxy_set_header cookie $http_cookie; proxy_set_header x-forwarded-host $host; proxy_set_header x-forwarded-server $host; proxy_set_header x-forwarded-for $proxy_add_x_forwarded_for; proxy_set_header host $host; proxy_set_header x-real-ip $remote_addr; gzip on; sendfile on; server { listen 8100; server_name localhost; location =/ { root /users/abee/webstormprojects/angular/dist; index index.html index.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_pass http://localhost:8200/; } } }
如果有多个server端location可使用另一种配置
location /server1/ { proxy_pass http://localhost:8300/; }
以上就是本次给大家带来的关于nginx实现前后端分离的全部内容,感谢你对的支持。
上一篇: Nginx实现非套路镜像站的踩坑记录
下一篇: 配置Nginx实现简单防御cc攻击