Under windows, configure multiple services with nginx

Everyone knows that nginx can configure proxy multiple services, and then use the access proxy service name to jump to the back-end corresponding service; currently in my project, I use nodejs as the back-end service. I have just contacted nginx not long ago. Configure multiple services under the same nginx, choose to use different ports, that is to say to modify listen
Insert picture description here
but what I want to do is, the default port 80 remains unchanged, use multiple service names for configuration (to facilitate the configuration of the port in the code), and then I changed the server_name in several servers in one operation,
Insert picture description here
Insert picture description here

But if you call localhost.hw or localhost.cs, you will get an error. Checking the route is also wrong. Then you find that the hosts file in Windows is not configured; the
path of the hosts file: C:\Windows\System32\drivers\etc\hosts
and then configure the hosts
Insert picture description here
Then refresh dns in cmd to make the configuration take effect:
ipconfig /flushdns,
restart nginx, visit http://localhost.cs, the proxy is successful (As for the'/' problem behind the path, it is about the nginx redirection configuration problem. Those interested can go to Baidu)
Insert picture description here

Guess you like

Origin blog.csdn.net/pjw1217/article/details/111694980