部署-鄂尔多斯水利项目
该项目是部署在内网环境中的,但是配置了外网ip,关键点在于,配置nginx方向代理时,注意ip,需要配置内网的ip,之前配置了外网ip导致接口调不通
一、准备环境
1.jdk1.8
2.mysql5.7
3.nginx最新版
4.linux服务器
二、前端项目打包(两个dist包)
具体打包流程我就不打包了,交给前端去打包,只需要配置后端服务器接口地址即可
三、后端项目打包
1.logback-spring.xml
日志文件修改存放路径
2.application.yml
配置文件修改端口、开发环境等:
3.application-dev.yml
配置文件修改数据库地址、文件上传相关配置等:
4.执行打包命令
四、配置nginx服务
使用nginx配置图片服务、部署前端项目(两个dist包)
具体配置:
user www-data;
worker_processes auto;
pid /run/nginx.pid;
error_log /var/log/nginx/error.log;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server {
listen 8005;
server_name 192.168.211.249;
resolver 8.8.8.8 valid=60s;
resolver_timeout 3s;
#水利-后台
location / {
root /home/remotesense/shuiliFiles/distFiles/dist-ht;
index index.html index.htm;
}
#配置请求跨域问题-后台
location /proxyApi/ {
proxy_pass http://192.168.211.249:8011/water/;
proxy_set_header host $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;
}
#nginx图片服务配置
location /images/ {
root /home/remotesense/shuiliFiles/;
autoindex on;
}
}
server {
listen 8006;
server_name 192.168.211.249;
resolver 8.8.8.8 valid=60s;
resolver_timeout 3s;
#水利-官网
location / {
root /home/remotesense/shuiliFiles/distFiles/dist;
index index.html index.htm;
}
#配置请求跨域问题-官网
location /water/ {
proxy_pass http://192.168.211.249:8011/water/;
proxy_set_header host $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;
}
}
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
本文来自博客园,作者:青喺半掩眉砂,转载请注明原文链接:https://www.cnblogs.com/xiaoguo-java/p/17695845.html