puma / puma-dev

A tool to manage rack apps in development with puma
BSD 3-Clause "New" or "Revised" License
1.74k stars 107 forks source link

Cannot configure puma-dev to use ipv6 proxy #336

Open ybart opened 1 year ago

ybart commented 1 year ago

For some reason my webpack-dev-server was listening only on ipv6 instead of both ipv4 and ipv6.

netstat -an | grep "[.]3035 .*LISTEN"
tcp6       0      0  ::1.3035               *.*                    LISTEN

A web browser has typically no big issue with this as it would try both ipv4 and ipv6.

For instance, http://localhost:3035/packs/js/runtime.js correctly works in a browser or with curl when webpack-dev-server is only listening to ipv6.

However, when only specifying '3035' in ~/.puma-dev/webpack, I only get the following entry in logs :

14:05:00 puma-dev.1 | 2023/05/26 14:05:00 http: proxy error: dial tcp 127.0.0.1:3035: connect: connection refused

And the browser logs a 502 (Bad Gateway) error.

The log clearly indicated it tried to connect with ipv4, whereas all system actually uses ipv6 elsewhere.

I think it would be nice if we were able to have a similar behaviour, so the fact webpacker-dev-server is not listening on ipv4 would cause no issue and puma-dev would be transparently proxying to ipv6 without the user noticing any issue.

Alternatively, it might also be useful in some situations to redirect explicitly to ipv6 address.

I tried to specify other values in ~/.puma-dev/webpack like '[::1]:3035' or 'http://[::1]:3035' but this only caused parser errors (I had to run puma-dev -uninstall and puma-dev -install to see the error in the log). However http://localhost:3035 worked around the issue.