TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Support HTTP over Unix domain sockets

46 点作者 denysonique超过 1 年前

17 条评论

_flux超过 1 年前
Yes, please! It would be so much better for local apps that have a management UI at a certain port: for one, you need to find such a free port. That&#x27;s right, 8000, 8008, 8080, 8888, some of those might be taken already ;).<p>In addition you can rely on Unix access control with the socket. Much better than granting access to all local users, such as is the case by default with e.g. Syncthing.<p>OpenSSH can also forward these sockets, so remote use can be safer that way and the port configuration issue is relevant here as well.<p>I&#x27;ve also hoped that NFS and its ilk would be able to transfer Unix domain sockets, but I haven&#x27;t heard of a system that could do that. Then one could, in principle, just ssh &#x2F;var&#x2F;servers&#x2F;gw over NFS!<p>edit: actually read the proposal and it mentions most of my points, including Syncthing :).
rwmj超过 1 年前
curl can do this: <a href="https:&#x2F;&#x2F;curl.se&#x2F;libcurl&#x2F;c&#x2F;CURLOPT_UNIX_SOCKET_PATH.html" rel="nofollow noreferrer">https:&#x2F;&#x2F;curl.se&#x2F;libcurl&#x2F;c&#x2F;CURLOPT_UNIX_SOCKET_PATH.html</a><p>It&#x27;s pretty useful in test suites where you don&#x27;t want to open a public TCP port (even on localhost), for obvious security reasons but also because it&#x27;s hard to pick an unused port without conflicting with other tests running at the same time. Example test using this: <a href="https:&#x2F;&#x2F;gitlab.com&#x2F;nbdkit&#x2F;nbdkit&#x2F;-&#x2F;blob&#x2F;master&#x2F;tests&#x2F;test-curl.c?ref_type=heads" rel="nofollow noreferrer">https:&#x2F;&#x2F;gitlab.com&#x2F;nbdkit&#x2F;nbdkit&#x2F;-&#x2F;blob&#x2F;master&#x2F;tests&#x2F;test-cu...</a>
评论 #38432437 未加载
评论 #38432547 未加载
erinaceousjones超过 1 年前
This sounds great - and I wish UNIX namespaces were adopted more widespread for things like &quot;local configurtion web UI&quot;.<p>As a workaround, (I believe, though only through a cursory web search and haven&#x27;t tested) you can use network namespaces and socat to proxy traffic from Unix sockets to a private IP:port range only visible to your user - taking that part of containerization without necessarily having to execute things inside containers.
p4bl0超过 1 年前
The actually interesting discussion is here: <a href="https:&#x2F;&#x2F;github.com&#x2F;whatwg&#x2F;url&#x2F;issues&#x2F;577">https:&#x2F;&#x2F;github.com&#x2F;whatwg&#x2F;url&#x2F;issues&#x2F;577</a> with the more constructive and detailed proposition starting from here: <a href="https:&#x2F;&#x2F;github.com&#x2F;whatwg&#x2F;url&#x2F;issues&#x2F;577#issuecomment-1185345177">https:&#x2F;&#x2F;github.com&#x2F;whatwg&#x2F;url&#x2F;issues&#x2F;577#issuecomment-118534...</a><p>I like the idea of specifying the socket in place of the port number in the URL.
评论 #38433025 未加载
nine_k超过 1 年前
&gt; <i>Getting this to actually work would be a bit difficult, for very little benefit.</i><p>I wonder why an actually secure local connection to a web UI is considered to be of <i>very little benefit</i>. This sounds crazy to me, for all these years.
评论 #38432638 未加载
philsnow超过 1 年前
CUPS listening on a localhost port and asking you to authenticate with your username and actual password has long bothered me. (I know it’s a privileged port, I just don’t like the idea of ever typing my local password into any browser, ever.)<p>I haven’t seen this proposal yet in this thread: instead of convincing browser vendors to support connecting to Unix domain sockets, contrive a tiny adapter which listens on a localhost port and expects http with basic auth (and either generates a random username and password or accepts them by environment variables), prints out a url with the password like<p><pre><code> Hi! To connect to your service at &#x2F;tmp&#x2F;whatever-service.unix, tell your browser to go to http:&#x2F;&#x2F;fwahjiddbjko:derhhkiytdfbkifdx@localhost:45678&#x2F; </code></pre> and then the adapter accepts connections, checks the auth, and then proxies the connection to the unix socket.<p>You could do this with nginx really easily but you’d have to keep track of a config file for each service.<p>See <a href="https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;17701420&#x2F;bypassing-http-basic-auth-locally" rel="nofollow noreferrer">https:&#x2F;&#x2F;stackoverflow.com&#x2F;questions&#x2F;17701420&#x2F;bypassing-http-...</a> for a similar idea (but that is about stripping auth, not adding it)
评论 #38433305 未加载
stop50超过 1 年前
I use nginx for that. I would like to see more software that provides the option to listen to unix sockets. Most still won&#x27;t work with unix sockets. Some prometheus exporters at least support systemd socket units.
评论 #38432251 未加载
评论 #38432424 未加载
评论 #38432441 未加载
评论 #38431978 未加载
metafunctor超过 1 年前
But, Docker doesn&#x27;t even, and I&#x27;m on Windows, whoever needed access control, waah waah. &lt;&#x2F;s&gt;<p>Unix domain sockets are great. I find it completely amazing that they are not used more widely.<p>Since when was it OK to open a TCP listener when you don&#x27;t want to receive connections over the network? Did everyone forget about that during their Kuberenetes fling, am I too old, or what?
paroneayea超过 1 年前
This would lead to a massive confused deputy vulnerability for unix domain sockets as already exists for localhost + port.<p>For a great example of this, see how Guile&#x27;s live REPL was localhost + port... cool, only local users could access it, right? Except browsers could access localhost + port, and it turned out this was a path to being able to do arbitrary code execution in the browser <a href="https:&#x2F;&#x2F;lists.gnu.org&#x2F;archive&#x2F;html&#x2F;guile-user&#x2F;2016-10&#x2F;msg00007.html" rel="nofollow noreferrer">https:&#x2F;&#x2F;lists.gnu.org&#x2F;archive&#x2F;html&#x2F;guile-user&#x2F;2016-10&#x2F;msg000...</a><p>Switching to unix domain sockets was the recommended path, and that&#x27;s <i>only</i> because browsers don&#x27;t support them.<p>If you want to support unix domain sockets, you could, but it would have to be via object capability security discipline, and the poster explicitly talks about an ACL &quot;protecting&quot; things... it wouldn&#x27;t.<p>Luckily this is 3 years old and hopefully will never make progress.
评论 #38433249 未加载
aldonius超过 1 年前
The WHATWG discussion (linked from OP thread) is also interesting:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;whatwg&#x2F;url&#x2F;issues&#x2F;577">https:&#x2F;&#x2F;github.com&#x2F;whatwg&#x2F;url&#x2F;issues&#x2F;577</a>
andix超过 1 年前
I&#x27;m not convinced that this is a good idea for a general purpose browser.<p>For web based desktop applications this might be a good solution. But there it is usually done with custom IPC. I think Electron can do it with custom protocols.<p>Listening on localhost is usually not a great solution. It&#x27;s impossible to do HTTPS right this way (without HTTPS there is a danger of a MITM attack from an unprivileged process). Also authentication is an issue then, without authentication there is a possibility of an privilege escalation.
评论 #38433279 未加载
评论 #38433312 未加载
josephcsible超过 1 年前
&gt; I would argue that the main reason it seems niche is because of the lack of browser support.<p>This can&#x27;t be said enough times. Browser vendors should never, ever say &quot;we&#x27;re not supporting feature X because it&#x27;s not popular enough, and other browsers don&#x27;t support it&quot; when lack of browser support is what&#x27;s keeping it from getting popular. We&#x27;d literally never get any new features if they always used that logic.
claudex超过 1 年前
No update in 3 years, not sure it will be implemented in foreseeable future
mildmotive超过 1 年前
Trackers will be able to gain root access by fetching the user’s local Docker API socket, and by doing so provide better personalized ads. This is really good, sign me in!
est超过 1 年前
I assume there are some clever gdb hacks out there to swap any http fd with another.
评论 #38432272 未加载
评论 #38432168 未加载
H4ZB7超过 1 年前
why do i have to be exposed to these people who don&#x27;t have the slightest clue about how the computer works? i want out. i don&#x27;t want to use an ecosystem that includes these people to be part of what runs on my computer. why would i want arbitrary web pages to be able to connect to all my daemons that expected that outsiders can&#x27;t connect to them including stuff like X and god knows what else. it&#x27;s bad enough that browsers can already connect to localhost which has already single handedly enabled hundreds of thousands of vulnerabilities in the form of &quot;attacker&#x27;s page (even with js disabled) accesses your local daemon from some 10th level nested iframe ad crap&quot;<p>i want out of this community. all these little people who have zero contextual understanding always requesting and implementing these features at all costs as long as the idea exists. this is a un*x problem at the core: if a feature conceptually exists, we must implement it at all costs. and another un*x problem here is having a global namespace (tcp port numbers) that things are just exposed to everything (either localhost or the network) by default when they could have easily just used an opaqaue handle that the machine operator can copy and paste into whatever application he wants to use it (no some openauth type shit that failed to be secure for 15 years is not what i have in mind)
评论 #38432929 未加载
peterhull90超过 1 年前
I personally would like to see it but I think there would need to be a solution for Windows too, since that is nearly 70% of desktop OS use vs. 20% for MacOS and 3% for Linux.[0] Otherwise it would be a lot of work for the benefit.<p>[0]: <a href="https:&#x2F;&#x2F;gs.statcounter.com&#x2F;os-market-share&#x2F;desktop&#x2F;worldwide&#x2F;#monthly-202210-202310" rel="nofollow noreferrer">https:&#x2F;&#x2F;gs.statcounter.com&#x2F;os-market-share&#x2F;desktop&#x2F;worldwide...</a>
评论 #38432871 未加载