一、停止 nginx 服务并关闭开机自启动
systemctl stop nginx
systemctl disable nginx
二、安装 apache
yum install httpd
systemctl restart httpd
三、部署前端
/var/www/html/ 下创建 test 目录,将 test-ui.zip 解压到该目录下
四、部署后端
执行命令:
nohup java -jar xxx.jar -&
注:后端应用运行在 18080 端口。
五、配置 httpd.conf
修改 /etc/httpd/conf/httpd.conf,在文件最后增加以下内容:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule rewrite_module modules/mod_rewrite.so
<Directory "/var/www/html/isms2">
RewriteEngine on
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.html [L]
AllowOverride All
Require all granted
</Directory>
<VirtualHost *:80>
ServerName localhost
ProxyPass /test/prod-api http://localhost:18080
ProxyPassReverse /test/prod-api http://localhost:18080
</VirtualHost>
注:Nginx 的配置如下:
server {
listen 80;
server_name localhost;
location /test {
alias /home/project/ui;
try_files $uri $uri/ /test/index.html;
index index.html index.htm;
}
location /test/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_connect_timeout 100;
proxy_read_timeout 100;
proxy_send_timeout 100;
proxy_pass http://localhost:18080/;
}
}
原文地址:https://blog.csdn.net/u012069313/article/details/129384863
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。