hostty 0.1.1.alpha-aarch64-linux-gnu → 0.1.2.alpha-aarch64-linux-gnu
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/docs/features/configuration.md +3 -0
- data/docs/features/domains.md +41 -1
- data/lib/hostty/nginx_template.rb +33 -0
- data/lib/hostty/process_config.rb +20 -3
- data/lib/hostty/templates/proxy.conf.erb +48 -0
- data/lib/hostty/templates/rails.conf.erb +104 -0
- data/lib/hostty/version.rb +1 -1
- data/lib/hostty.rb +1 -0
- metadata +4 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 21279f6e43aa617aa759c9659f061baacf1bbbf3ba50729c5daaf5d08b472164
|
|
4
|
+
data.tar.gz: 933de8ee4f9cd7d4563a0792228ea0d4f8cd6d4b88428cfcec0abf627167fc4a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d67f7ec4f8c82d48eea7df3b7aa31db880c3ee80f9413b972bd90a7e3c252d9e43dd1ada96aa8d59fb24e05251fdc0c818d92cde909707c7fdabaa1b36d99072
|
|
7
|
+
data.tar.gz: b8809036eedcebfc1d8332f4ae9ea7eb5b32f8bcd258b510112597954a4a8228750b6f23ce55ffc7e55758657d5293f41aae2b800b8abdfb6119e6f412fa65a8
|
|
@@ -64,6 +64,8 @@ Hostty starts the processes in the order of the file. The tabs and the [ports](#
|
|
|
64
64
|
| `ssl` | No | Serve the domain over HTTPS. Defaults to `false`. |
|
|
65
65
|
| `log` | No | Write NGINX access and error logs for the domain to `~/.ruby-nginx/logs`. Defaults to `false`. |
|
|
66
66
|
| `host` | No | The address that the domain points to and that NGINX sends requests to. Defaults to `127.0.0.1`. |
|
|
67
|
+
| `root` | No | The directory NGINX serves static files from, relative to the config file. See [NGINX Configs](./domains.md#nginx-configs). |
|
|
68
|
+
| `template` | No | The NGINX server config for the domain: `"rails"`, `"proxy"`, or the path to an ERB file. See [NGINX Configs](./domains.md#nginx-configs). |
|
|
67
69
|
| `port` | No | A port number, or `"random"`. See [Ports](#ports). |
|
|
68
70
|
| `env` | No | More environment variables for the process. |
|
|
69
71
|
|
|
@@ -119,6 +121,7 @@ Hostty stops before it adds a domain or starts a process when the config file ha
|
|
|
119
121
|
| A `skip_used_ports` that is not `true` or `false` | `skip_used_ports must be true or false.` |
|
|
120
122
|
| A process with no command | `<name> needs a command.` |
|
|
121
123
|
| A process setting hostty does not know | `<name> has unknown settings: <settings>.` |
|
|
124
|
+
| A `root` or `template` that is not text | `<name> needs a text value for its <setting>.` |
|
|
122
125
|
| A port that is not a number from 1 to 65535, or `"random"` | `<name> needs a port from 1 to 65535, or "random".` |
|
|
123
126
|
| A port in use, with `skip_used_ports: false` | `Port <port> for <name> is in use. Free the port, or set skip_used_ports to true.` |
|
|
124
127
|
| A port number that is in use | `Port <port> for <name> is in use. Free the port, or change the port of <name>.` |
|
data/docs/features/domains.md
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
### Contents
|
|
11
11
|
|
|
12
12
|
- [What a Domain Does](#what-a-domain-does)
|
|
13
|
+
- [NGINX Configs](#nginx-configs)
|
|
13
14
|
- [When Hostty Adds a Domain](#when-hostty-adds-a-domain)
|
|
14
15
|
- [Prompts](#prompts)
|
|
15
16
|
- [When a Domain Fails](#when-a-domain-fails)
|
|
@@ -41,7 +42,46 @@ flowchart LR
|
|
|
41
42
|
nginx -- "localhost:5000" --> web[web process]
|
|
42
43
|
```
|
|
43
44
|
|
|
44
|
-
The [settings](./configuration.md#settings)
|
|
45
|
+
The [process settings](./configuration.md#process-settings) table lists `ssl`, `log`, `host`, `root`, and `template`.
|
|
46
|
+
|
|
47
|
+
## NGINX Configs
|
|
48
|
+
|
|
49
|
+
The `template` setting picks the NGINX server config for the domain. It takes the name of a built-in config or the path to your own file:
|
|
50
|
+
|
|
51
|
+
| `template` | What NGINX does |
|
|
52
|
+
| --- | --- |
|
|
53
|
+
| Not set | Serves a file from `root` when one matches the path, and sends every other request to the process. |
|
|
54
|
+
| `"rails"` | Serves a file from `root` when one matches the path, and sends every other request to the process. `root` defaults to `public`. Allows uploads up to 4 GB and waits 30 minutes for a response, so a debugger can pause a request. |
|
|
55
|
+
| `"proxy"` | Sends every request to the process, and serves no files itself. Use it for a dev server that serves its own files, such as Jekyll or Vite. |
|
|
56
|
+
| A path, such as `"config/nginx.conf.erb"` | Uses your own file. The path is relative to the config file. |
|
|
57
|
+
|
|
58
|
+
```yaml
|
|
59
|
+
processes:
|
|
60
|
+
web:
|
|
61
|
+
command: "bin/rails server -p $PORT"
|
|
62
|
+
domain: "shop.test"
|
|
63
|
+
ssl: true
|
|
64
|
+
template: "rails"
|
|
65
|
+
docs:
|
|
66
|
+
command: "bundle exec jekyll serve --port $PORT"
|
|
67
|
+
domain: "docs.shop.test"
|
|
68
|
+
template: "proxy"
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
Set `root` for any config that serves files. Without it, NGINX serves every file in the project directory, including secrets such as `.env`.
|
|
72
|
+
|
|
73
|
+
### Writing Your Own
|
|
74
|
+
|
|
75
|
+
Start from the [ruby-nginx default template](https://github.com/bert-mccutchen/ruby-nginx/blob/main/lib/ruby/nginx/templates/nginx.conf.erb). The template can use these values:
|
|
76
|
+
|
|
77
|
+
- `name`: a name for the upstream block, made from the domain.
|
|
78
|
+
- `options[:domain]`, `options[:port]`, `options[:host]`, and `options[:root_path]`.
|
|
79
|
+
- `options[:ssl]`, `options[:ssl_certificate_path]`, and `options[:ssl_certificate_key_path]`.
|
|
80
|
+
- `options[:log]`, `options[:access_log_path]`, and `options[:error_log_path]`.
|
|
81
|
+
- `options[:temp_path]`: a directory NGINX can write temp files to. Set `proxy_temp_path` and `client_body_temp_path` to it, or NGINX can fail with a permissions error.
|
|
82
|
+
- `nginx_version`: the installed NGINX version.
|
|
83
|
+
|
|
84
|
+
When the file does not exist, hostty prints the error and starts no process. A file named `rails` or `proxy` needs a path such as `"./rails"`, so hostty does not read it as a built-in config.
|
|
45
85
|
|
|
46
86
|
## When Hostty Adds a Domain
|
|
47
87
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Hostty
|
|
4
|
+
class NginxTemplate
|
|
5
|
+
def initialize(name:, base_path:)
|
|
6
|
+
@name = name
|
|
7
|
+
@base_path = base_path
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def path
|
|
11
|
+
return File.expand_path("templates/#{name}.conf.erb", __dir__) if built_in?
|
|
12
|
+
|
|
13
|
+
File.expand_path(name, base_path)
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def static_root
|
|
17
|
+
root = STATIC_ROOTS[name]
|
|
18
|
+
File.expand_path(root, base_path) if root
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
private
|
|
22
|
+
|
|
23
|
+
STATIC_ROOTS = {
|
|
24
|
+
"rails" => "public",
|
|
25
|
+
"proxy" => nil
|
|
26
|
+
}.freeze
|
|
27
|
+
private_constant :STATIC_ROOTS
|
|
28
|
+
|
|
29
|
+
attr_reader :name, :base_path
|
|
30
|
+
|
|
31
|
+
def built_in? = STATIC_ROOTS.key?(name)
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -40,7 +40,8 @@ module Hostty
|
|
|
40
40
|
{
|
|
41
41
|
domain:,
|
|
42
42
|
port:,
|
|
43
|
-
root_path
|
|
43
|
+
root_path: static_root,
|
|
44
|
+
template_path: template&.path,
|
|
44
45
|
host: settings["host"],
|
|
45
46
|
ssl: settings["ssl"],
|
|
46
47
|
log: settings["log"]
|
|
@@ -49,9 +50,10 @@ module Hostty
|
|
|
49
50
|
|
|
50
51
|
private
|
|
51
52
|
|
|
52
|
-
KEYS = %w[command domain port ssl log host env].freeze
|
|
53
|
+
KEYS = %w[command domain port ssl log host root template env].freeze
|
|
54
|
+
PATH_KEYS = %w[root template].freeze
|
|
53
55
|
PORTS = 1..65_535
|
|
54
|
-
private_constant :KEYS, :PORTS
|
|
56
|
+
private_constant :KEYS, :PATH_KEYS, :PORTS
|
|
55
57
|
|
|
56
58
|
attr_reader :settings, :default_port, :ports
|
|
57
59
|
|
|
@@ -61,9 +63,24 @@ module Hostty
|
|
|
61
63
|
raise ConfigError, "#{name} needs a command." unless present_string?(command)
|
|
62
64
|
raise ConfigError, "#{name} needs a port from 1 to 65535, or \"random\"." unless valid_port_setting?
|
|
63
65
|
raise ConfigError, "#{name} needs a text value for its domain." unless domain.nil? || present_string?(domain)
|
|
66
|
+
raise ConfigError, "#{name} needs a text value for its #{invalid_path_keys.join(" and ")}." if invalid_path_keys.any?
|
|
64
67
|
raise ConfigError, "#{name} needs a list of names and values for its env." unless settings.fetch("env", {}).is_a?(Hash)
|
|
65
68
|
end
|
|
66
69
|
|
|
70
|
+
def invalid_path_keys
|
|
71
|
+
PATH_KEYS.select { |key| settings.key?(key) && !present_string?(settings[key]) }
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
def template
|
|
75
|
+
@template ||= NginxTemplate.new(name: settings["template"], base_path: root_path) if settings["template"]
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def static_root
|
|
79
|
+
return File.expand_path(settings["root"], root_path) if settings["root"]
|
|
80
|
+
|
|
81
|
+
template&.static_root || root_path
|
|
82
|
+
end
|
|
83
|
+
|
|
67
84
|
def unknown_keys
|
|
68
85
|
settings.keys.map(&:to_s) - KEYS
|
|
69
86
|
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
map $http_upgrade $connection_upgrade {
|
|
2
|
+
default upgrade;
|
|
3
|
+
'' close;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
upstream <%= name %> {
|
|
7
|
+
server <%= options[:host] %>:<%= options[:port] %> fail_timeout=0;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
server {
|
|
11
|
+
listen 80;
|
|
12
|
+
server_name <%= options[:domain] %>;
|
|
13
|
+
|
|
14
|
+
<% if options[:ssl] %>
|
|
15
|
+
<% if nginx_version >= Ruby::Nginx::Version.new("1.25.1") %>
|
|
16
|
+
listen 443 ssl;
|
|
17
|
+
http2 on;
|
|
18
|
+
<% else %>
|
|
19
|
+
listen 443 ssl http2;
|
|
20
|
+
<% end %>
|
|
21
|
+
ssl_certificate <%= options[:ssl_certificate_path] %>;
|
|
22
|
+
ssl_certificate_key <%= options[:ssl_certificate_key_path] %>;
|
|
23
|
+
<% end %>
|
|
24
|
+
|
|
25
|
+
<% if options[:log] %>
|
|
26
|
+
access_log <%= options[:access_log_path] %> combined buffer=512k flush=1m;
|
|
27
|
+
error_log <%= options[:error_log_path] %> warn;
|
|
28
|
+
<% end %>
|
|
29
|
+
|
|
30
|
+
proxy_temp_path <%= options[:temp_path] %> 1 2;
|
|
31
|
+
client_body_temp_path <%= options[:temp_path] %> 1 2;
|
|
32
|
+
|
|
33
|
+
location / {
|
|
34
|
+
proxy_pass http://<%= name %>;
|
|
35
|
+
proxy_http_version 1.1;
|
|
36
|
+
proxy_no_cache 1;
|
|
37
|
+
proxy_cache_bypass 1;
|
|
38
|
+
|
|
39
|
+
proxy_set_header Host $host;
|
|
40
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
41
|
+
proxy_set_header Connection $connection_upgrade;
|
|
42
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
43
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
44
|
+
proxy_set_header X-Forwarded-Proto $scheme;
|
|
45
|
+
proxy_set_header X-Forwarded-Host $host;
|
|
46
|
+
proxy_set_header X-Forwarded-Port $server_port;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
map $http_upgrade $connection_upgrade {
|
|
2
|
+
default upgrade;
|
|
3
|
+
'' close;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
map $remote_addr $proxy_forwarded_elem {
|
|
7
|
+
~^[0-9.]+$ "for=$remote_addr";
|
|
8
|
+
~^[0-9A-Fa-f:.]+$ "for=\"[$remote_addr]\"";
|
|
9
|
+
default "for=unknown";
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
map $http_forwarded $proxy_add_forwarded {
|
|
13
|
+
"~^(,[ \\t]*)*([!#$%&'*+.^_`|~0-9A-Za-z-]+=([!#$%&'*+.^_`|~0-9A-Za-z-]+|\"([\\t \\x21\\x23-\\x5B\\x5D-\\x7E\\x80-\\xFF]|\\\\[\\t \\x21-\\x7E\\x80-\\xFF])*\"))?(;([!#$%&'*+.^_`|~0-9A-Za-z-]+=([!#$%&'*+.^_`|~0-9A-Za-z-]+|\"([\\t \\x21\\x23-\\x5B\\x5D-\\x7E\\x80-\\xFF]|\\\\[\\t \\x21-\\x7E\\x80-\\xFF])*\"))?)*([ \\t]*,([ \\t]*([!#$%&'*+.^_`|~0-9A-Za-z-]+=([!#$%&'*+.^_`|~0-9A-Za-z-]+|\"([\\t \\x21\\x23-\\x5B\\x5D-\\x7E\\x80-\\xFF]|\\\\[\\t \\x21-\\x7E\\x80-\\xFF])*\"))?(;([!#$%&'*+.^_`|~0-9A-Za-z-]+=([!#$%&'*+.^_`|~0-9A-Za-z-]+|\"([\\t \\x21\\x23-\\x5B\\x5D-\\x7E\\x80-\\xFF]|\\\\[\\t \\x21-\\x7E\\x80-\\xFF])*\"))?)*)?)*$" "$http_forwarded, $proxy_forwarded_elem";
|
|
14
|
+
default "$proxy_forwarded_elem";
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
map $http_x_forwarded_proto $proxy_forwarded_proto {
|
|
18
|
+
default $http_x_forwarded_proto;
|
|
19
|
+
'' $scheme;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
map $http_x_forwarded_host $proxy_forwarded_host {
|
|
23
|
+
default $http_x_forwarded_host;
|
|
24
|
+
'' $host;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
upstream <%= name %> {
|
|
28
|
+
server <%= options[:host] %>:<%= options[:port] %> fail_timeout=0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
server {
|
|
32
|
+
listen 80;
|
|
33
|
+
server_name <%= options[:domain] %>;
|
|
34
|
+
root <%= options[:root_path] %>;
|
|
35
|
+
try_files $uri/index.html $uri @<%= name %>;
|
|
36
|
+
|
|
37
|
+
<% if options[:ssl] %>
|
|
38
|
+
<% if nginx_version >= Ruby::Nginx::Version.new("1.25.1") %>
|
|
39
|
+
listen 443 ssl;
|
|
40
|
+
http2 on;
|
|
41
|
+
<% else %>
|
|
42
|
+
listen 443 ssl http2;
|
|
43
|
+
<% end %>
|
|
44
|
+
ssl_certificate <%= options[:ssl_certificate_path] %>;
|
|
45
|
+
ssl_certificate_key <%= options[:ssl_certificate_key_path] %>;
|
|
46
|
+
<% end %>
|
|
47
|
+
|
|
48
|
+
<% if options[:log] %>
|
|
49
|
+
access_log <%= options[:access_log_path] %> combined buffer=512k flush=1m;
|
|
50
|
+
error_log <%= options[:error_log_path] %> warn;
|
|
51
|
+
<% end %>
|
|
52
|
+
|
|
53
|
+
proxy_temp_path <%= options[:temp_path] %> 1 2;
|
|
54
|
+
client_body_temp_path <%= options[:temp_path] %> 1 2;
|
|
55
|
+
|
|
56
|
+
large_client_header_buffers 4 16k;
|
|
57
|
+
client_max_body_size 4G;
|
|
58
|
+
keepalive_timeout 75s;
|
|
59
|
+
|
|
60
|
+
proxy_connect_timeout 1800;
|
|
61
|
+
proxy_send_timeout 1800;
|
|
62
|
+
proxy_read_timeout 1800;
|
|
63
|
+
|
|
64
|
+
location @<%= name %> {
|
|
65
|
+
proxy_pass http://<%= name %>;
|
|
66
|
+
proxy_http_version 1.1;
|
|
67
|
+
proxy_no_cache 1;
|
|
68
|
+
proxy_cache_bypass 1;
|
|
69
|
+
|
|
70
|
+
proxy_buffer_size 128k;
|
|
71
|
+
proxy_buffers 4 256k;
|
|
72
|
+
proxy_busy_buffers_size 256k;
|
|
73
|
+
|
|
74
|
+
proxy_set_header Host $host;
|
|
75
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
76
|
+
proxy_set_header Connection $connection_upgrade;
|
|
77
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
78
|
+
proxy_set_header Forwarded $proxy_add_forwarded;
|
|
79
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
80
|
+
proxy_set_header X-Forwarded-Proto $proxy_forwarded_proto;
|
|
81
|
+
proxy_set_header X-Forwarded-Host $proxy_forwarded_host;
|
|
82
|
+
proxy_set_header X-Forwarded-Port $server_port;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
location ^~ /assets/ {
|
|
86
|
+
proxy_pass http://<%= name %>;
|
|
87
|
+
proxy_http_version 1.1;
|
|
88
|
+
proxy_no_cache 1;
|
|
89
|
+
proxy_cache_bypass 1;
|
|
90
|
+
|
|
91
|
+
proxy_set_header Host $host;
|
|
92
|
+
proxy_set_header Upgrade $http_upgrade;
|
|
93
|
+
proxy_set_header Connection $connection_upgrade;
|
|
94
|
+
proxy_set_header X-Real-IP $remote_addr;
|
|
95
|
+
proxy_set_header Forwarded $proxy_add_forwarded;
|
|
96
|
+
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
97
|
+
proxy_set_header X-Forwarded-Proto $proxy_forwarded_proto;
|
|
98
|
+
proxy_set_header X-Forwarded-Host $proxy_forwarded_host;
|
|
99
|
+
proxy_set_header X-Forwarded-Port $server_port;
|
|
100
|
+
|
|
101
|
+
add_header Cache-Control public;
|
|
102
|
+
add_header Access-Control-Allow-Origin *;
|
|
103
|
+
}
|
|
104
|
+
}
|
data/lib/hostty/version.rb
CHANGED
data/lib/hostty.rb
CHANGED
|
@@ -10,6 +10,7 @@ require "ruby/nginx"
|
|
|
10
10
|
require_relative "hostty/version"
|
|
11
11
|
require_relative "hostty/exceptions"
|
|
12
12
|
require_relative "hostty/port_chooser"
|
|
13
|
+
require_relative "hostty/nginx_template"
|
|
13
14
|
require_relative "hostty/process_config"
|
|
14
15
|
require_relative "hostty/config"
|
|
15
16
|
require_relative "hostty/output"
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: hostty
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2.alpha
|
|
5
5
|
platform: aarch64-linux-gnu
|
|
6
6
|
authors:
|
|
7
7
|
- Bert McCutchen
|
|
@@ -83,11 +83,14 @@ files:
|
|
|
83
83
|
- lib/hostty/manager/events.rb
|
|
84
84
|
- lib/hostty/manager/process_exited.rb
|
|
85
85
|
- lib/hostty/manager/signal_received.rb
|
|
86
|
+
- lib/hostty/nginx_template.rb
|
|
86
87
|
- lib/hostty/output.rb
|
|
87
88
|
- lib/hostty/plain/app.rb
|
|
88
89
|
- lib/hostty/plain/pipe.rb
|
|
89
90
|
- lib/hostty/port_chooser.rb
|
|
90
91
|
- lib/hostty/process_config.rb
|
|
92
|
+
- lib/hostty/templates/proxy.conf.erb
|
|
93
|
+
- lib/hostty/templates/rails.conf.erb
|
|
91
94
|
- lib/hostty/terminal/cell.rb
|
|
92
95
|
- lib/hostty/terminal/style.rb
|
|
93
96
|
- lib/hostty/tui/app.rb
|