benjie / mehserve Goto Github PK
View Code? Open in Web Editor NEWA simple port-sharing proxy for development on multiple local domains, supports websockets
License: MIT License
A simple port-sharing proxy for development on multiple local domains, supports websockets
License: MIT License
sudo mkdir -p /usr/local/share/ca-certificates/mehserve
sudo cp ~/.mehserve/blah.ssl.crt /usr/local/share/ca-certificates/mehserve/blah.ssl.crt
sudo update-ca-certificates
# For chrome/etc
certutil -d sql:$HOME/.pki/nssdb -A -t "C,," -n blah -i ~/.mehserve/blah.ssl.crt
~ ๐ ๐ mehserve run --exponential-backoff
Exponential backoff enabled, with 25 attempts
mehserve v2.0.0-2 listening on port 12439
mehserve v2.0.0-2 (SSL) listening on port 12443
_http_server.js:188
throw new RangeError(`Invalid status code: ${originalStatusCode}`);
^
RangeError: Invalid status code: ECONNRESET
at ServerResponse.writeHead (_http_server.js:188:11)
at ServerResponse._implicitHeader (_http_server.js:179:8)
at write_ (_http_outgoing.js:630:9)
at ServerResponse.end (_http_outgoing.js:749:5)
at /usr/local/lib/node_modules/mehserve/index.js:71:7
at cb (/usr/local/lib/node_modules/mehserve/index.js:205:34)
at ClientRequest.proxyError (/usr/local/lib/node_modules/mehserve/node_modules/http-proxy/lib/http-proxy/passes/web-incoming.js:154:11)
at emitOne (events.js:115:13)
at ClientRequest.emit (events.js:210:7)
at Socket.socketOnEnd (_http_client.js:421:9)
This was caused by a server that accepted the connection then closed the socket without sending any data.
From what I can see in the readme:
So, there's no way, short of digging through the code, to say, change the port of a registered service.
Now, by digging through the code, I can now see that service "foo" is registered as port 8081 simply by creating a file ~/.mehserve/foo
with contents 8081
.
I'd suggest:
mehserve ls
command that lists the registered services (by scanning that directory) with their portssudo apt-get install dnsmasq
echo -e "local=/dev/\naddress=/dev/127.0.0.1" | sudo tee /etc/dnsmasq.d/dev-tld
echo -e "local=/meh/\naddress=/meh/127.0.0.1" | sudo tee /etc/dnsmasq.d/meh-tld
sudo service dnsmasq restart
sudo iptables -t nat -A OUTPUT -o lo -p tcp --dport 80 -j REDIRECT --to-port 12439
sudo iptables-save
This would also mean that we can disable the DNS server on linux since dnsmasq serves this purpose for us. Shame we can't do platform-specific dependencies in npm!
Error is disconcerting.
I mean, when I go to foo.dev
which is configured with pow it will autostart the application, and close it after a while if not used.
In Node 17+, making requests to *.meh
domains from within Node (e.g. via built-in fetch
) is failing with Error: connect ECONNREFUSED ::1:443
.
Turns out that Node 17 changes the default sorting order for DNS records so that IPv4 records are no longer sorted ahead of IPv6 by default: nodejs/node#39987
So instead of using 127.0.0.1
, requests now resolve to ::1
as the default behaviour.
The cause of the failed requests (at least on MacOS) seems to be this line in meh.firewall.plist
: if I change 127.0.0.1
to ::1
it appears to all go back to a working state, however, I'm not smart enough to understand why, so I'm hesitant to make a PR suggesting a change! But it looks to be something with the firewall rule not forwarding traffic in an IPv6 friendly way.
Hope that's useful! ๐
Cool repo! It's working nicely.
However when I try to connect to my Vue app running at localhost:8080, through your proxy, I get a document containing "Invalid Host header". And that's all I get! (Directly at localhost:8080 it works fine). Do you know if this error is something that comes from mehserve?
Hey, @benjie! I just installed mehserve and I'm really impressed with what you've done!
I tried to add a self-signed cert using mehserve ssl <sitename>
and I got the following message:
SSL certificate successfully generated
================================================================================
We'll open Keychain Access in a moment. Here are the instructions what to do:
1. Click "Add"
2. Find the certificate (e.g. "chocolate") in the "Certificates" category,
select it, and click the [๏ฝ] button at the bottom
3. In the popup window, click the โถ button to the left of 'Trust', and select
'Always Trust' for 'When using this certificate:'.
4. Close the popup window.
5. When prompted, enter your password again and click Update Settings.
6. Quit Keychain Access.
Press enter to continue
Error: open exited with status '1'
at ChildProcess.<anonymous> (/usr/local/lib/node_modules/mehserve/ssl.js:15:16)
at ChildProcess.emit (events.js:210:5)
at maybeClose (internal/child_process.js:1021:16)
at Socket.<anonymous> (internal/child_process.js:430:11)
at Socket.emit (events.js:210:5)
at Pipe.<anonymous> (net.js:659:12)
I popped open keychain myself to see if the certificate had been added, but I don't see it in there at all. Any advice?
It seems like it should just gracefully handle this and retry the connection every few seconds.
mehserve v1.1.1 listening on port 12439
/Users/jeffrey/.nvm/versions/node/v5.5.0/lib/node_modules/mehserve/node_modules/http-proxy/lib/http-proxy/index.js:119
throw err;
^
Error: connect ECONNREFUSED 127.0.0.1:9001
at Object.exports._errnoException (util.js:856:11)
at exports._exceptionWithHostPort (util.js:879:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1062:14)
port 15353
that is hard-coded right now is also used by corectl
Note: I also opened an issue on corectl: TheNewNormal/corectl#106
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.