This article is a mirror article of machine translation, please click here to jump to the original article.

View: 348|Reply: 0

[.NET Core] Nginx reverse proxy ASP.NET Core use UDS communication

[Copy link]
Posted on 2025-9-18 10:36:51 | | | |
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:
.NET/C# processes communicate between gRPC and Unix domain sockets
https://www.itsvse.com/thread-11051-1-1.html

The Nginx reverse proxy php-fpm uses UDS to communicate
https://www.itsvse.com/thread-11068-1-1.html

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.




Previous:The Nginx reverse proxy php-fpm uses UDS to communicate
Next:The SQL Server server modifies the database collation rules
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com