Nginx實(shí)現(xiàn)前后端分離
更新時(shí)間:2018年02月08日 08:44:18 投稿:laozhang
本篇文章是小編整理的關(guān)于Nginx實(shí)現(xiàn)前后端分離的詳細(xì)代碼,如果你對此有需要,可以參考測試下。
#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/;
}
}
}
如果有多個(gè)server端location可使用另一種配置
location /server1/ {
proxy_pass http://localhost:8300/;
}
以上就是本次給大家?guī)淼年P(guān)于Nginx實(shí)現(xiàn)前后端分離的全部內(nèi)容,感謝你對腳本之家的支持。
相關(guān)文章
使用Nginx Ingress 優(yōu)雅顯示錯(cuò)誤頁面
這篇文章主要為大家介紹了使用Nginx Ingress 優(yōu)雅顯示錯(cuò)誤頁面實(shí)現(xiàn)示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-09-09
詳解Keepalived+Nginx實(shí)現(xiàn)高可用(HA)
這篇文章主要介紹了詳解Keepalived+Nginx實(shí)現(xiàn)高可用(HA),小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2018-06-06
503 service unavailable錯(cuò)誤解決方案講解
這篇文章主要介紹了503 service unavailable錯(cuò)誤解決方案講解,本篇文章通過簡要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下2021-08-08
使用Nginx部署前端Vue項(xiàng)目的實(shí)現(xiàn)
本文主要介紹了使用Nginx部署前端Vue項(xiàng)目的實(shí)現(xiàn),通過將這兩者結(jié)合起來,我們可以高效地托管我們的前端應(yīng)用,下面就一起來介紹一下,感興趣的可以了解一下2024-09-09
nginx里的rewrite跳轉(zhuǎn)的實(shí)現(xiàn)
這篇文章主要介紹了nginx里的rewrite跳轉(zhuǎn)的實(shí)現(xiàn),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-11-11

