使用Nginx 反向代理,通过域名直接访问Tomcat 8080端口
环境为腾讯云的CentOS 7.5 64位
①安装nginx
[root@VM_0_14_centos ~]# yum install nginx -y
②修改配置文件
进入默认配置文件的目录
[root@VM_0_14_centos webapp]# cd /etc/nginx
vim编辑nginx.conf
[root@VM_0_14_centos nginx]# vim nginx.conf
修改server部分
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
proxy_pass http://服务器IP:8080/;
}
error_page 404 /404.html;
location = /40x.html {
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
}
}
wq保存退出
nginx -t 测试配置文件
[root@VM_0_14_centos nginx]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful
启动nginx
[root@VM_0_14_centos nginx]# nginx
之前启动过了,重启nginx
[root@VM_0_14_centos nginx]# nginx -s reload
设置开机自启动nginx
[root@VM_0_14_centos nginx]# chkconfig nginx on
小记,完
还没有评论,来说两句吧...