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万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章