A few days ago, I set up a forum server and put it in the company's LAN. The forum used port 9066 and made a port forwarding on the router, and pointed the domain name bbs.xxx.com to the company's public domain. Network IP,Because I don’t want users to enter the port number when accessing, I want to make a jump on the company’s web server and transfer all requests to access bbs.xxx.com to his server. My first thought was Using nginx's rewrite, the process is very simple. The configuration is as follows:
server {
listen 80;
server_name bbs.xxx.com;
rewrite "^/(.*)$" http://bbs.xxx.com:9066/$1 break;
} }
So visit bbs I checked .xxx.com and found that all operations such as registration, login and posting were normal. I thought it would be ok, but then a problem occurred. Although it could jump normally, the address on the domain name bar of the user's browser kept following. 9066 This port number made the leader very dissatisfied, so I looked for nginx documentation and asked other friends in the QQ group, but there was no good solution. So I used it instead proxy_pass, this configuration is also very simple:
server {
listen 80;
server_name bbs.xxx.com;
location /
}
}
Single IP within one day You can only register 5 times", what happened, I found out after checking the logs All requests sent from the public network turned out to be the IP address of the gateway. Now I understood that after simply adding proxy, if there is no further setting, nginx will not judge the real client IP, but will directly add it. The routing address is used as the request IP, so the above situation will occur. After analysis, I checked the nginx wiki and added a few more entries:
server {listen 80;
server_name bbs.xxx.com;
location /
proxy_set_header Host $host;
proxy_set_header 066/;
After the modification, I reloaded nginx and found that the source IP in the log was already the real client address. Re-registration, login, and posting were all normal. After repeating it many times, no problem was found, and everything was normal at the customer's end.
Thanks to Sanmen Diesel for providing me with enthusiastic help.
The following is an article I found on the Internet. The analysis is very detailed http://www.beijus.info/?p=730&cpage=1. I also want to thank the author of this article "Dandan Noodles"
The above introduces an example of nginx domain name jump~~~rewrite and proxy, including the content. I hope it will be helpful to friends who are interested in PHP tutorials.