宝塔部署项目

前端项目 VUE 前端端口 8801

VUE APP BASE API =http://localhost:8801/prod-api/' /prod-api 指向后端 往下面看

宝塔部署项目插图

JAVA 后端yml 端口号8801

druid 多数据源 就是你多个库会用到这个 比如A库和B库都有user表

宝塔部署项目插图1

下面看Nginx 配置

宝塔部署项目插图2

user www www; worker_processes auto; error_log /www/wwwlogs/nginx_error.log crit; pid /www/server/nginx/logs/nginx.pid; worker_rlimit_nofile 51200; events { use epoll; worker_connections 51200; multi_accept on; } http { include mime.types; #include luawaf.conf; include proxy.conf; default_type application/octet-stream; server_names_hash_bucket_size 512; client_header_buffer_size 32k; large_client_header_buffers 4 32k; client_max_body_size 50m; sendfile on; tcp_nopush on; keepalive_timeout 60; tcp_nodelay on; fastcgi_connect_timeout 300; fastcgi_send_timeout 300; fastcgi_read_timeout 300; fastcgi_buffer_size 64k; fastcgi_buffers 4 64k; fastcgi_busy_buffers_size 128k; fastcgi_temp_file_write_size 256k; fastcgi_intercept_errors on; gzip on; gzip_min_length 1k; gzip_buffers 4 16k; gzip_http_version 1.1; gzip_comp_level 2; gzip_types text/plain application/javascript application/x-javascript text/javascript text/css application/xml; gzip_vary on; gzip_proxied expired no-cache no-store private auth; gzip_disable "MSIE [1-6]\."; limit_conn_zone $binary_remote_addr zone=perip:10m; limit_conn_zone $server_name zone=perserver:10m; server_tokens off; access_log off; # server # { # listen 80; # server_name 47.104.23.18 localhost; # #error_page 404 /404.html; # include enable-php.conf; # location / { # root /code/dist; # try_files $uri $uri/ /index.html; # index index.html index.htm; # } # location /prod-api/{ # proxy_set_header Host $http_host; # proxy_set_header X-Real-IP $remote_addr; # proxy_set_header REMOTE-HOST $remote_addr; # proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # proxy_pass http://localhost:8080/; # } # location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ # { # expires 30d; # } # location ~ .*\.(js|css)?$ # { # expires 12h; # } # location ~ /\. # { # deny all; # } # access_log /www/wwwlogs/access.log; # } # access_log /www/server/nginx/conf/log/access.log; # error_log /www/server/nginx/conf/log/error.log; # 这里的意思是你子配置文件的地方 #include /www/server/panel/vhost/nginx/*.conf; include /www/server/nginx/conf/enabled/*.conf; } 

include /www/server/nginx/conf/enabled/*.conf; 每个端口对应的一个文件

宝塔部署项目插图3

最后像下面的这种

宝塔部署项目插图4

下面看service配置

listen 80 关于这个 你前端访问是什么就写什么端口 进行反向代理

server { #前端访问的端口 listen 80; server_name 47.104.23.18 localhost; #error_page 404 /404.html; include enable-php.conf; location / { # 这里放你的前端目录 root /code/dist; try_files $uri $uri/ /index.html; index index.html index.htm; } location /prod-api/{ proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 这里是你后端的IP 端口 proxy_pass http://localhost:8801/; } }

原文链接:https://blog.csdn.net/weixin_56408993/article/details/128222713

© 版权声明
THE END
喜欢就支持一下吧
点赞13 分享