vue项目部署nginx,配置

Posted lazyli

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vue项目部署nginx,配置相关的知识,希望对你有一定的参考价值。

#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;
	#include reverse-procy.conf;
    server #vue前端页面访问ip,端口
        listen       8090;
        server_name  10.9.1.179;
		
		default_type ‘text/html‘;
		
        charset utf-8;

        location / #vue项目打包资源路径
            root   E:/javaworkspace/project/rbApi/dist;
            index  index.html;
        
		
		location /api/ #Java后台接口,比如:http://10.9.1.179:8082/api/updateAnnouncement;
			proxy_pass http://10.9.1.179:8082;
			
			
		

        error_page   500 502 503 504  /50x.html;
        location = /50x.html 
            root   html;
        



    
	server #映射端口Java后台服务器真正的端口
        listen       8082;
        server_name  10.9.1.179;
		
		default_type ‘text/html‘;
		
        charset utf-8;

        location / 
            root   html;
            index  getstep.html index.html index.htm;
        
		
		location /api/ #Java服务器项目服务地址
			proxy_pass http://10.9.1.179:8071;
			
			
			
		

        error_page   500 502 503 504  /50x.html;
        location = /50x.html 
            root   html;
        



    


  

以上是关于vue项目部署nginx,配置的主要内容,如果未能解决你的问题,请参考以下文章

vue项目nginx必备配置-----API 接口代理

Nginx本地部署Vue项目

vue项目用nginx写好项目本地先试试路路径问题

Vue项目打包部署到Nginx服务器

vite+vue3 项目打包部署

vue项目部署方式:tomcat部署和nginx部署