linux服務器使用nginx部署react、vue項目配置?

配置文件地址 #nginx/conf/con.d/default.conf

server {
    listen       80;
    server_name  0.0.0.0; #外網ip  
    client_max_body_size 20m; 
    #charset koi8-r;
    access_log  /var/log/nginx/access.log  main;

    location / {  # 攔截請求靜態頁面地址/home/dist下
        root   /home/dist;
        index  index.html index.htm  login.html;
        add_header Access-Control-Allow-Origin *;
    }
   
    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    location ^~/api/ {
     proxy_pass   http://0.0.0.0:8080/; # 攔截所有"/api/"的http請求轉發到內網ip
    }
}

 

react和vue項目使用nginx部署其中一種配置方法

發佈了30 篇原創文章 · 獲贊 38 · 訪問量 14萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章