多个vue项目nginx部署流程

nginx部署流程
#在nginx.conf中配置
#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;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;
	#一个服务88,服务名client ;后台提供的接口proxy_pass http://127.0.0.1:8888/;地址
    server {
      listen  88;
      server_name client;
       location / {
            root   html/client;
            index  index.html index.htm;
            try_files $uri $uri/ /index.html;
        }
        location /api/ {
            proxy_pass http://127.0.0.1:8888/;
        }
      error_page 500 502 503 504 /50x.html;
      location = /50x.html {
       root html;
      }
	}
	server {
        listen       89;
        server_name magent;
       location / {
       #在html中创建magent文件夹,存放编译后的前端vue文件
            root   html/magent;
            index  index.html index.htm;
            try_files $uri $uri/ /index.html;
        }
        location /api/ {
            proxy_pass http://127.0.0.1:8888/;
        }
      error_page 500 502 503 504 /50x.html;
      location = /50x.html {
       root html;
      } 
    }
}

启动服务
#ca到目录下
cd /usr//local/nginx

#启动nginx
./nginx

#停止,重新加载配置文件
./nginx -s stop
./nginx -s reload
访问的时候访问
localhost:88
localhost:89
posted @ 2024-07-02 16:00  爱豆技术部  阅读(27)  评论(0)    收藏  举报
TOP