Home > Article > Backend Development > nginx+tomcat binding domain name configuration record
Record the domain name binding process using nginx as reverse proxy and tomcat as web container.
First of all, of course, you need to configure the domain name in the domain name manager to point to your own server IP (of course, it’s a big deal if you don’t even have a domain name!)
Then it’s time to configure nginx,
Find nginx/conf/nginx.conf and make the following key configurations:
upstream xx{ #配置upstream节点,这里节点名为“xx”
server 116.255.111.111:8080;
}
server{
listen 80;
server_name www.xxx.xx; #这里配置nginx需要代理的域名
location / {
proxy_pass http://xx; #指定反向代理为上面配置的那个upstream节点“xx”
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
That’s it for the basic configuration of nginx. If you want to bind multiple domain names, you can Configure several more servers and change the server_name and port of the server.
The upstream node specifies the access path to the proxy service, which can be used for load balancing. For details, see: http://tengine.taobao.org/book/chapter_05.html#upstream-100
There is a lot of information about nginx online, here is an example: http://tengine.taobao.org/book/index.html
Now you can start tomcat on the server. After startup, enter the domain name in the browser to access it, and it works! The page is out! It’s just that the default interface of tomcat comes out. Now, we need to configure tomcat so that the request can enter the specified project.
"www.xxx.xx" appBase="/opt/tomcat7.0/webapps/testweb" unpackWARs="true" autoDeploy="true">
"" docBase="/opt/tomcat7.0/webapps/testweb" debug="0" reloadable="true" />
"org.apache.catalina.valves.AccessLogValve" directory="logs" prefix="localhost_access_log." suffix=".txt" pattern="%h%l%u%t "%r" %s%b" />
</Host>
Okay, now restart tomcat, visit "www.xxx.xx", and jump to "/opt/tomcat7.0/webapps/ The project under "testweb" has gone.
The configuration is very personal experience and cannot be fully referenced. I will only briefly note it here.
The above introduces the nginx+tomcat binding domain name configuration record, including the relevant content. I hope it will be helpful to friends who are interested in PHP tutorials.