Nginx教程

nginx 配置例子

本文主要是介绍nginx 配置例子,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

nginx 配置

配置文件上传大小

client_max_body_size  40m;

保存后 nginx -s reload 后还是不行,
解决:采用taskkill /f /im nginx.exe命令杀死进程,再stat nginx 就行了。。。

配置vue

server {
    listen       8192;
    server_name  suncereltd.6655.la;
    client_max_body_size 500m;
    proxy_max_temp_file_size 500m;

    location / {
       root   /home/water/suncere.direct.networking.water.frontend/dist/;
       try_files $uri $uri/ /index.html;
   }


    location /api/base/
  	{
  		proxy_pass http://localhost:4483;
  	}
  	location /api/business/
  	{
  		proxy_pass http://localhost:4483;
  	}
  	location /wwww/.*\.(docx|doc)
  	{
  		proxy_pass http://localhost:4483;
  	}
  	location ~ .*\.(docx)$
  	{
  	   #proxy_pass http://localhost:4483;
         root /home/water/water-direct/wwwroot/download/;
  	}
    #location ~ .*\.(docx)$
  	#{
  	#   proxy_pass http://localhost:4483;
  	#}
}

单个端口,用路径区分,配置2个vue项目

server {
    listen       8321;
    server_name  suncereltd.6655.la;

    location /map/ {
        # root   /home/tongchuan/dist;
        alias    /home/weifang/map/;
        index  index.html index.htm;
    }
    location / {
        root   /home/weifang/map/;
        index  index.html index.htm;
    }
    location /bs/ {
        # root   /home/tongchuan/dist;
        alias    /home/weifang/water/;
        index  index.html index.htm;
    }
    location /App_Data/AduitFiles/ {
       root   /home/weifang/webhost;
  	}

    location ^~ /static/outlet/ {
         rewrite ^/(.*) http://suncereltd.6655.la:8321/#/$1 last;
    }
    # location /api/ {
    #     proxy_pass   http://localhost:4402/api/;
    # }
    location /api/ {
        proxy_pass   http://localhost:8328/api/;
    }

}
这篇关于nginx 配置例子的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!