Skip to content

Commit

Permalink
allow port binding on macos for non-root user and adjust README
Browse files Browse the repository at this point in the history
  • Loading branch information
vandot committed Apr 12, 2023
1 parent 99de63c commit ac635f0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
19 changes: 12 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# lodev
lodev is a simple reverse proxy server for local development with SSL termination.

Obsoletes using ngrok or manually configuring combination of mkcert, dnsmasq and nginx/caddy. It provides HTTPS endpoint under `https://dev.lo` and by default proxies all requests to `http://127.0.0.1:3000`.
Obsoletes using ngrok or manually configuring combination of mkcert, dnsmasq and nginx/caddy. It provides HTTPS endpoint under `https://*.dev.lo` and by default proxies all requests to `http://127.0.0.1:3000`.

It uses [locert](https://github.com/vandot/locert) to generate and install locally trusted SSL certs and [lodns](https://github.com/vandot/lodns) for DNS name resolution.

Expand All @@ -15,23 +15,28 @@ Download correct binary from the latest [release](https://github.com/vandot/lode
Or `nimble install lodev`

## Configuration
lodev comes preconfigured for all supported platforms to act as a HTTPS reverse proxy server behind `dev.lo` domain.
lodev comes preconfigured for all supported platforms to act as a HTTPS reverse proxy server behind `*.dev.lo` domain.

On MacOS and Linux you have to run with `sudo` to be able to configure the system
On MacOS and Linux it will ask for sudo password
```
sudo lodev install
lodev install
```
On Windows run inside elevated command prompt or Powershell
```
lodev.exe install
```

## Start
Service must be started with elevated priviledges because it will bind to a well-known port `443`. By default service will proxy all requests to `127.0.0.1:3000`. You can specify different destination port using `-p=8000`.
Service will bind to a well-known port `443`. By default service will proxy all requests to `127.0.0.1:3000`. You can specify different destination port using `-p=8000`.

On Linux add CAP_NET_BIND_SERVICE capability to the lodev binary to able to bind port 443 as a non-root user.
```
sudo setcap cap_net_bind_service=+eip lodev
```

On MacOS and Linux
```
sudo lodev start
lodev start
```
On Windows inside elevated command prompt or Powershell
```
Expand All @@ -41,7 +46,7 @@ lodev.exe start
## Uninstallation
On MacOS and Linux run
```
sudo lodev uninstall
lodev uninstall
```
On Windows run inside elevated command prompt or Powershell
```
Expand Down
2 changes: 1 addition & 1 deletion lodev.nimble
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Package

version = "0.1.0"
version = "0.1.1"
author = "vandot"
description = "Simple reverse proxy server for local development"
license = "MIT"
Expand Down
4 changes: 3 additions & 1 deletion src/lodev/proxy.nim
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,9 @@ proc join*(rs: SecureProxyServerRef): Future[void] =
rs.server.join()

proc createServer*(proxy: ProxyServer): SecureProxyServerRef =
let address = initTAddress("127.0.0.1:443")
var address = initTAddress("127.0.0.1:443")
when defined macosx: # https://developer.apple.com/forums/thread/674179
address = initTAddress("0.0.0.0:443")
let secureKey = TLSPrivateKey.init(readFile(proxy.cert[1]))
let secureCert = TLSCertificate.init(readFile(proxy.cert[0]))
let sres = SecureProxyServerRef.new(proxy, address, secureKey,
Expand Down

0 comments on commit ac635f0

Please sign in to comment.