preface
Recently, I ran into a pit, hit a lot of walls, and got rid of it so I’m going to record it here. It is also convenient for you to step on less pits if you encounter them later.
The Nginx server forwarding Node interface looks something like this.
For example, if I use Node to develop a/API /getList interface on the cloud server and listen on port 6600, then we can use Nginx to do this.
http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; gzip on; Upstream {server 127.0.0.1:6600 max_fails=2 fail_timeout=5s; } server { listen 80;Host name or domain nameserver_name www.xxx.com; location / { proxy_pass http://springboot; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; }}}Copy the code
So in this way can request: http://www.xxx.com/api/getList/, the request is actually on the cloud server http://127.0.0.1:6600/api/getList/.
Yes, it’s not graphical, but I personally find this imperative more convenient (I probably use Nginx a lot).
In actual combat
After we look at Nginx Settings, let’s look at how IIS forwards.
Let’s set it up step by step.
1. Install ARR 3.0 (Application Request Routing) and configure it
The install link: https://www.iis.net/downloads/microsoft/application-request-routing.
After the installation is successful, run the following command on the CLI to restart the IIS server.
iisreset
Copy the code
You can see the Application Request Routing icon on the features page.
Then, we double click the icon to enter the function setting page. After entering, click on the right barServer Proxy Settings.
Finally, select Enable Proxy and leave the other options as they are. Then, click the Apply button and save.
Rewrite (URL Rewrite)
The install link: https://www.iis.net/downloads/microsoft/url-rewrite.
Once installed, the URL rewrite button is visible on the IIS Capabilities View page.
Double-click the URL Rewrite button to go to the Settings page. Then, click the Add Rule button in the right sidebar.
Select the white space rule and click OK.
The edit inbound rule page is displayed.
Based on the previous interface, we can set it like this. You can come up with a name that’s easy to remember, so I’m going to go with 6600. Because our interface is/API /getList, and there may be/API /getList1, / API /getList2, etc., the regular expression pattern character is determined here.*? /? The API/(. *) $. Finally, we set the URL to be rewritten, that is, [http://localhost:6600/{R:0}](http://localhost:6600/{R:0}), and click Apply to save.
Now that we’re configured, we see our list of 6600 items.
The domain name www.xxx.com is already bound to IIS. So can also request like this: http://www.xxx.com/api/getList/, the request is actually on the cloud server http://127.0.0.1:6600/api/getList/.
conclusion
IIS configuration is more graphical and should be more user-friendly, but the fact is that there are a lot of additional steps that make the experience much more complex than just a few lines of Nginx configuration files. So, I personally prefer Nginx.
About the author
Author: Vam’s Golden Bean Road. He won the title of CSDN Annual Blog Star in 2019, and the accumulated visits of CSDN blog and gold digging technology community have exceeded 2 million.
Public number: front-end experience rob road, focus on front-end technology sharing and learning, thank you for your attention to me. Learning front-end technology is like experiencing disaster after disaster. Only persistence and hard work will make you a god in your heart! ‘~