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
tar -xvf caddy.tar.gz --strip-components=0 -C /tmp/caddy
71
-
72
-
sudo cp /tmp/caddy/caddy /usr/local/bin/
73
-
```
74
-
75
-
* Create a Caddyfile
76
-
77
-
The `Caddyfile` configures which websites Caddy will expose, and which sites need a TLS certificate.
78
-
79
-
Replace `service.example.com` with your own domain.
80
-
81
-
Next, edit `proxy / 127.0.0.1:8000` and change the port `8000` to the port of your local webserver, for instance `3000` or `8080`. For our example, keep it as `8000`.
82
-
83
-
```sh
84
-
service.example.com
85
-
86
-
proxy / 127.0.0.1:8000 {
87
-
transparent
88
-
}
52
+
inlets-pro fileserver --webroot ./ \
53
+
--allow-browsing
89
54
```
90
55
91
-
Start the Caddy binary, it will listen on port 80 and 443.
92
-
93
-
```
94
-
sudo ./caddy
95
-
```
56
+
The command listens on port `8080` by default, but you can change is as desired with `--port`
96
57
97
-
If you have more than one website, you can add them to the Caddyfile on new lines.
58
+
The `--allow-browsing` flag allows directory listing and traversal through the browser.
98
59
99
-
> You'll need to run caddy as `sudo` so that it can bind to ports 80, and 443 which require additional privileges.
60
+
If you're sharing files with a colleague or friend, you can add `--allow-browsing=false` and share the exact URL with them instead.
100
61
101
62
## Start the inlets-pro client on your local side
102
63
@@ -123,29 +84,9 @@ inlets-pro tcp client \
123
84
124
85
Note that `--upstream localhost` will connect to Caddy running on your computer, if you are running Caddy on another machine, use its IP address here.
125
86
126
-
## Check it all worked
127
-
128
-
You'll see that Caddy can now obtain a TLS certificate.
129
-
130
-
Go ahead and visit: `https://service.example.com`
131
-
132
-
Congratulations, you've now served a TLS certificate directly from your laptop. You can close caddy and open it again at a later date. Caddy will re-use the certificate it already obtained and it will be valid for 3 months. To renew, just keep Caddy running or open it again whenever you need it.
133
-
134
87
## Setup Caddy 2.x
135
88
136
-
For Caddy 2.x, the Caddyfile format changes.
137
-
138
-
Let's say you're running a Node.js service on port 3000, and want to expose it with TLS on the domain "service.example.com":
The local site will be served at http://127.0.0.1:3000
89
+
Here's an example Caddyfile that will reverse-proxy to the local file-server using the domain name `service.example.com`:
149
90
150
91
```Caddyfile
151
92
{
@@ -154,22 +95,26 @@ The local site will be served at http://127.0.0.1:3000
154
95
155
96
service.example.com
156
97
157
-
reverse_proxy 127.0.0.1:3000 {
98
+
reverse_proxy 127.0.0.1:8080 {
158
99
}
159
100
```
160
101
161
102
Note the `acme_ca` being used will receive a staging certificate, remove it to obtain a production TLS certificate.
162
103
163
-
Now [download Caddy 2.x](https://caddyserver.com/download) for your operating system.
104
+
Now [download Caddy 2.x](https://caddyserver.com/download) for your operating system. You can get it from the downloads page, or if you're a Linux user on an amd64 or arm64 machine, you can use arkade to do everything required via `arkade system install caddy`. See `arkade system install --help` for more options.
105
+
106
+
Once you have the binary, you can run it with the following command:
164
107
165
108
```bash
166
109
sudo ./caddy run \
167
110
-config ./Caddyfile
168
111
```
169
112
170
-
`sudo` - is required to bind to port 80 and 443, although you can potentially update your OS to allow binding to low ports without root access.
113
+
`sudo` - is required to bind to port 80 and 443, although you can potentially update your OS to allow binding to low ports without root access. See this [StackOverflow question for more](https://superuser.com/questions/710253/allow-non-root-process-to-bind-to-port-80-and-443).
171
114
172
-
You should now be able to access the Node.js website via the `https://service.example.com` URL.
115
+
You should now be able to access the fileserver via the `https://service.example.com` URL.
116
+
117
+
If you wanted to expose something else like Grafana, you could simply edit your Caddyfile's `reverse_proxy` line, then restart Caddy.
173
118
174
119
Caddy also supports multiple domains within the same file, so that you can expose multiple internal or private websites through the same tunnel.
175
120
@@ -187,5 +132,12 @@ openfaas.example.com {
187
132
}
188
133
```
189
134
190
-
If you have services running on other machines you can change `127.0.0.1:8080` to a different IP address such as that of your Raspberry Pi if you had something like [OpenFaaS](https://github.com/openfaas/) running there.
135
+
If you have services running on other machines you can change `127.0.0.1:8080` to a different IP address such as that of your Raspberry Pi if you had something like [OpenFaaS CE](https://github.com/openfaas/faas) or [faasd CE](https://github.com/openfaas/faasd) running there.
136
+
137
+
## Check it all worked
191
138
139
+
You'll see that Caddy can now obtain a TLS certificate.
140
+
141
+
Go ahead and visit: `https://service.example.com`
142
+
143
+
Congratulations, you've now served a TLS certificate directly from your laptop. You can close caddy and open it again at a later date. Caddy will re-use the certificate it already obtained and it will be valid for 3 months. To renew, just keep Caddy running or open it again whenever you need it.
0 commit comments