Requirements: ASP.NET Core already supports listening to UDS (Unix domain socket), if Nginx and ASP.NET Core sites are on the same server, they can actually communicate directly through UDS, and Unix domain sockets usually have less overhead and faster transmission speed than using TCP/IP.
Review:
First, to create a new .NET 8 web application, I encapsulated a ListenerUnix extension method with the following code:
In Program.cs, call as follows:
The code mainly supports urls parameters to enable http listening and Unix domain socket listening, and after the application is successfully launched,Set the Unix domain socket file permission to 777Otherwise, when nginx reverse proxy to UDS, otherwise it may report permission issues, as follows:
2025/09/17 11:01:26 [crit] 2887135#0: *112497 connect() to unix:/var/run/itsvse.socket failed (13: Permission denied) while connecting to upstream, client: x.x.x.x, server: itsvse.com, request: "GET / HTTP/2.0", upstream: "http://unix:/var/run/itsvse.socket:/", host: "itsvse.com" If you need to manually set the 777 permissions, the command is as follows:
If the Linux server cannot be sent to the Linux server, the startup is successful as shown in the following figure:
Using curl testing, the command is as follows:
As shown below:
The Nginx configuration is as follows:
The reverse proxy path is set up with two,One with :/, one without :/, you can distinguish the effect by requesting the output, as shown in the figure below:
Reference:
The hyperlink login is visible.
The hyperlink login is visible.
The hyperlink login is visible. |