- NGINX Cookbook
- Tim Butler
- 152字
- 2021-07-03 00:04:29
How it works....
There's only one main block directive to get our simple test working, with a few key areas.
proxy_pass http://127.0.0.1:3000;
The proxy will forward the connection back to our Express-driven test application, which we configured to listen on port 3000 of the localhost.
proxy_http_version 1.1;
By default, proxied connections back to the Node.js application will be HTTP/1.0 only. Setting this to HTTP/1.1 allows the use of keep-alive, which means the connection between NGINX and the application remains open rather than establishing a new connection every time. On a heavily loaded system, this is much more efficient.
proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade";
The WebSocket protocol uses the Upgrade and Connection headers as part of the handshake process. We need to set this at the NGINX level in order to allow the handshake process to work as expected. As it's compatible with HTTP/1.1, it won't interfere with the standard connections either.
- SpringMVC+MyBatis快速開發與項目實戰
- 算法基礎:打開程序設計之門
- Instant Zepto.js
- PyTorch Artificial Intelligence Fundamentals
- HBase從入門到實戰
- HTML5+CSS3基礎開發教程(第2版)
- 云原生Spring實戰
- JavaScript 程序設計案例教程
- Building an RPG with Unity 2018
- 零基礎學Python網絡爬蟲案例實戰全流程詳解(高級進階篇)
- 零基礎學Kotlin之Android項目開發實戰
- Hands-On GUI Programming with C++ and Qt5
- IDA Pro權威指南(第2版)
- Photoshop CC移動UI設計案例教程(全彩慕課版·第2版)
- 遠方:兩位持續創業者的點滴思考