最近的一个项目中药用到Nginx的反向代理功能,问题描述如下:网站已经部署好,现在只能通过ip:port来进行访问,现在要解决的问题是去掉这个port
安装nginx,在nginx.conf (路径是 /etc/nginx/nginx.conf 文件中http块内加入
include msite.conf;
然后新建msite.conf
假设本机ip为123.456.789.000 编辑如下
upstream tomcatserver1 {
server 123.456.789.000:9000;
}
server {
listen 80;
server_name 123.456.789.000;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://tomcatserver1;
index index.html index.htm;
}
}
之后检查配置文件是否正确,命令是nginx -t
若无问题,reload nginx 生效,命令是nginx -s reload