You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat: add shared tunnel server for cloud deployments
- Add TunnelServer class for single-port tunnel multiplexing
- Add --tunnel-port CLI option to enable shared tunnel mode
- Update TunnelAgent to optionally use shared TunnelServer
- Client sends ID on connect when sharedTunnel flag is set
- Server returns sharedTunnel: true and tunnelPort in response
- Document cloud deployment configuration in README
This fixes 404 errors when running pipenet server in containerized
environments like fly.io where only specific ports are exposed.
maxTcpSockets:10, // Optional: max sockets per client
111
+
tunnelPort:3001, // Optional: shared tunnel port for cloud deployments
108
112
});
109
113
114
+
// Start tunnel server if using shared tunnel port
115
+
if (server.tunnelServer) {
116
+
awaitserver.tunnelServer.listen(3001);
117
+
}
118
+
110
119
server.listen(3000, () => {
111
120
console.log('pipenet server listening on port 3000');
112
121
});
@@ -118,13 +127,45 @@ server.listen(3000, () => {
118
127
-`secure` (boolean) Require HTTPS connections
119
128
-`landing` (string) URL to redirect root requests to
120
129
-`maxTcpSockets` (number) Maximum number of TCP sockets per client (default: 10)
130
+
-`tunnelPort` (number) Shared tunnel port for cloud deployments (enables single-port mode)
121
131
122
132
### Server API Endpoints
123
133
124
134
-`GET /api/status` - Server status and tunnel count
125
135
-`GET /api/tunnels/:id/status` - Status of a specific tunnel
126
136
-`GET /:id` - Request a new tunnel with the specified ID
127
137
138
+
### Cloud Deployments
139
+
140
+
When deploying pipenet server to cloud platforms like fly.io, Docker, or Kubernetes, you typically can only expose a limited number of ports. By default, pipenet creates a random TCP port for each tunnel client, which doesn't work well in these environments.
141
+
142
+
Use the `--tunnel-port` option to enable single-port mode, where all tunnel clients connect to a single shared port:
143
+
144
+
```bash
145
+
# fly.io example
146
+
pipenet server --port 8080 --tunnel-port 8081 --domain tunnel.example.com --secure
147
+
```
148
+
149
+
Then expose both ports in your deployment configuration. For fly.io:
150
+
151
+
```toml
152
+
[[services]]
153
+
internal_port = 8080
154
+
protocol = "tcp"
155
+
[[services.ports]]
156
+
port = 80
157
+
handlers = ["http"]
158
+
[[services.ports]]
159
+
port = 443
160
+
handlers = ["http", "tls"]
161
+
162
+
[[services]]
163
+
internal_port = 8081
164
+
protocol = "tcp"
165
+
[[services.ports]]
166
+
port = 8081
167
+
```
168
+
128
169
## Why pipenet?
129
170
130
171
pipenet was developed by [glama.ai](https://glama.ai) to enable local [Model Context Protocol (MCP)](https://modelcontextprotocol.io/) servers to connect with remote AI clients (e.g., to give AI assistants access to your local file system).
0 commit comments