Ant Design Pro of Vue 用nginx代理部署Java项目连通

前端 专栏收录该内容
32 篇文章 0 订阅
npm run dev 打包
或
yarn build  打包
或
如下图均可以打包

在这里插入图片描述

打包后可以测试

npm install http-server -g 全局
http-server
或者
npm install -g serve(全局安装)
serve -s dist

打包后把打包生成的dist文件复制到nginx html目录
在这里插入图片描述

在这里插入图片描述
nginx相关命令

nginx config配置

  location / {
           root html/dist;
           index index.html index.htm;
           try_files $uri $uri/ /index.html;
        }

location /declarehelper {
	    proxy_set_header   X-Forwarded-Proto $scheme;
        proxy_set_header   Host              $http_host;
        proxy_set_header   X-Real-IP         $remote_addr;
        proxy_pass   http://localhost:8080/declarehelper/; 
		}

完整的nginx config如下


#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;

    server {
        listen       88;
        server_name  localhost;
        gzip on;
        gzip_min_length 1k;
        gzip_comp_level 9;
        gzip_types text/plain application/javascript application/x-javascript text/css application/xml text/javascript application/x-httpd-php image/jpeg image/gif image/png;
        gzip_vary on;
        gzip_disable "MSIE [1-6]\.";
        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
           root html/dist;
           index index.html index.htm;
           try_files $uri $uri/ /index.html;
        }
        
    
        #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   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
		
		location /declarehelper {
	    proxy_set_header   X-Forwarded-Proto $scheme;
        proxy_set_header   Host              $http_host;
        proxy_set_header   X-Real-IP         $remote_addr;
        proxy_pass   http://localhost:8080/declarehelper/; 
		}
    }


    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443 ssl;
    #    server_name  localhost;

    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_cache    shared:SSL:1m;
    #    ssl_session_timeout  5m;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers  on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}

}

springboot打包流程
在这里插入图片描述

在这里插入图片描述
打包成功之后

把java包复制到任意位置
启动

 java -jar xxxxxx.jar

相关命令

启动
 java -jar declarehelper-api.jar

查询进程  - -pid
wmic process where caption="java.exe" get processid,caption,commandline /value

根据pid  停止进程

taskkill /PID 1400 -t -f

相关vue命令记录(不一定用的到)

npm run dev 打包

yarn build  打包

全局安装打包生成器
npm install express-generator -g

全局安装
express declarehelper-vue
yarn install
yarn start


npm install http-server -g 全局

http-server


npm install -g serve(全局安装)

serve -s dist
  • 1
    点赞
  • 3
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

相关推荐
©️2020 CSDN 皮肤主题: 技术工厂 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值