Skip to content

Commit c6e4ba2

Browse files
committed
Migration re-application
Document proxied requests, Passenger standalone mode
1 parent 3364cae commit c6e4ba2

File tree

4 files changed

+120
-4
lines changed

4 files changed

+120
-4
lines changed

docs/admin/Apache.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@ ProxyPassReverse http://127.0.0.1:8080/
226226
</Location>
227227
```
228228

229+
229230
## Technical details
230231

231232
Apache is a custom build available through [apisnetworks/httpd-apache](https://github.com/apisnetworks/httpd-apache). Nonportable atomics are enabled as well as mod_systemd backported from Apache 2.5 development to facilitate lightweight service reports. Latest APR and APR Utility releases are bundled to maximize efficiency. Compilation targets x86-64 machines using default compile flags.
@@ -329,5 +330,5 @@ To bypass this message, add at least 1 hostname to the map file. This can be acc
329330

330331
For supporting documentation, see also
331332
- [PHP-FPM](PHP-FPM.md) - PHP
332-
- [Passenger](Passenger.md) - Node, Ruby, Python, and Go
333+
- [Passenger](webapps/Passenger.md) - Node, Ruby, Python, and Go
333334

docs/admin/Migrations - cPanel.md

Lines changed: 34 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,38 @@ Following migration, ApisCP will attempt to request SSL for each hostname as wel
149149

150150
`--unsafe-sources` allows importing unchecked, potentially hazardous, backup data including SquirrelMail preference files and Roundcube MySQL directives. The consistency and validity of this data is not checked. **Do not enable this option unless you are confident the backup has not been tampered with**.
151151

152-
### Quota disagreements
152+
### Reapplying components
153+
**New in 3.2.32**
154+
155+
`--list-components` enumerates all available components for a given backup. These components are determined by files present within the backup. `--do=COMPONENT` may be specified multiple times to reapply *only* those migration components.
156+
157+
```bash
158+
ImportDomain --list-components --format=cpanel cpmove.tar.gz
159+
# - apachetls
160+
# - cp
161+
# - cron
162+
# - dnszones
163+
# - homedir
164+
# - ips
165+
# - meta
166+
# - mm
167+
# - mysqlsql
168+
# - psql
169+
# - shadow
170+
# - shell
171+
# - userdata
172+
# - va
173+
# - version
174+
175+
# Reapply mailing list + database importation steps (mm, mysqlsql)
176+
ImportDomain --do=mm --do=mysqlsql --no-create --no-bootstrap --no-scan --format=cpanel cpmove.tar.gz
177+
```
178+
179+
In the above example, `--no-create --no-bootstrap --no-scan` are present. `--no-create` is to prevent account creation which is attempted automatically to ensure importing into a pristine environment. Likewise `--no-bootstrap` and `--no-scan` prevent end-of-import hooks from running, SSL acquisition and Web App updates.
180+
181+
### Troubleshooting
182+
183+
#### Quota disagreements
153184

154185
Quotas are accounted and enforced by the kernel. When migrating from certain hosting platforms that employ quasi-quota accounting by software, such as cPanel, the reported quota for a user may be significantly more than what was previously reported. `--late-quota` will apply storage amnesty, which is a 2x storage boost for 12 hours. **Late quota is only triggered** after account creation. Thus when combined with `--no-create`, `--late-quota` has no effect. Call `site:storage-amnesty` against the account using [cpcmd](CLI.md#cpcmd).
155186

@@ -162,11 +193,11 @@ cpcmd scope:set cp.config quota storage_duration 172800
162193

163194
These changes will be reflected on future imports.
164195

165-
### Decompression oddities
196+
#### Decompression oddities
166197

167198
Migration will attempt to use PHP's PharData handler to decompress files. It's based on USTAR, which has [limitations](https://www.gnu.org/software/tar/manual/html_node/Formats.html#Formats) that may result in a cPanel backup generated in POSIX.1-2001 standards to fail. Use `--no-builtin` to disable the builtin handler from attempting to read the backup.
168199

169-
### Empty MySQL credentials
200+
#### Empty MySQL credentials
170201

171202
Prior to MySQL 5.7.5 released in [2014](https://dev.mysql.com/doc/relnotes/mysql/5.7/en/news-5-7-5.html), MySQL accepted passwords created in an insecure hash format that was used prior to 4.1. From speculation, accounts that were created prior to this change were abandoned from a [secure upgrade pathway by cPanel](https://forums.cpanel.net/threads/mysql-upgrade-to-v-5-6-old-style-passwords-cpanel-explanation.649945/).
172203

docs/admin/Migrations - server.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,14 @@ apnscp_php bin/scripts/transfersite.php -c='dns,provider=linode' -c='dns,key=abc
8686

8787
On the source server, mydomain.com may continue to use DigitalOcean as its [DNS provider](https://bitbucket.org/apisnetworks/apnscp/src/master/lib/Module/Provider/Dns/Digitalocean.php?at=master&fileviewer=file-view-default) while the on the target server mydomain.com will use Linode's [DNS provider](https://bitbucket.org/apisnetworks/apnscp/src/master/lib/Module/Provider/Dns/Linode.php?at=master&fileviewer=file-view-default). Once mydomain.com completes its initial stage (stage 0), be sure to update the nameservers for mydomain.com.
8888

89+
## Notification templates
90+
91+
A notification is sent at the end **stage 0** (warmup migration) and **stage 1** (final migration). Migrations are read from `resources/templates/migrations/` and may be overrode following [view/template](Customizing.md#ApisCP) override rules.
92+
93+
Custom templates may be specified using `--template=`. A single argument or CLI
94+
8995
## Skipping suspension
96+
9097
An account after migration completes is automatically suspended on the source side. In normal operation, this poses no significant complications as DNS TTL is reduced to 2 minutes or less during stage one migration.
9198

9299
`--no-suspend` disables suspension following a successful migration.

docs/admin/webapps/Passenger.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,83 @@ Global idle shutdown may be modified by overriding `PassengerPoolIdleTime` in `/
6969
PassengerPoolIdleTime 0
7070
```
7171

72+
## Direct proxy
73+
74+
An application may wire in additional services that make automatic startup/shutdown by Passenger cumbersome, such as [Discourse](Discourse.md). A Passenger-based application can be manually started, then connected to using [mod_rewrite](https://httpd.apache.org/docs/2.4/mod/mod_rewrite.html).
75+
76+
If an application is running on port 8082, then the following rules in the *document root* of the subdomain or domain will suffice:
77+
78+
```
79+
DirectoryIndex disabled
80+
RequestHeader set X-Forwarded-Proto expr=%{REQUEST_SCHEME}
81+
82+
RewriteEngine On
83+
# This may be removed to send ALL requests to the app
84+
RewriteCond %{REQUEST_FILENAME} -f
85+
RewriteRule ^ - [L]
86+
87+
RewriteCond %{HTTP:Connection} =upgrade [NC]
88+
RewriteCond %{HTTP:Upgrade} =websocket [NC]
89+
RewriteRule ^(.*)$ ws://localhost:8082/$1 [L,QSA,P]
90+
RewriteRule ^(.*)$ http://localhost:8082/$1 [L,QSA,P]
91+
```
92+
93+
First, no [directory index](https://httpd.apache.org/docs/2.4/mod/mod_dir.html#directoryindex) will be assumed (index.html, index.php) for the location.
94+
95+
The request scheme (http, https) is passed to the proxy as X-Forwarded-Proto. This standard, recognized in [RFC 7239](https://datatracker.ietf.org/doc/html/rfc7239), informs the application if the request was made securely.
96+
97+
If the request matches a file in the document root, such as media or JavaScript, then that file is served directly.
98+
99+
If the client solicits a request to upgrade to WebSockets, then the ws protocol is used.
100+
101+
Otherwise the request is sent locally, unencrypted, to the application listening on port 8082.
102+
103+
### Standalone mode
104+
105+
Passenger includes a [standalone mode](https://www.phusionpassenger.com/library/config/standalone/intro.html) that facilitates launching an application directly, such as in the case of [Discourse](Discourse.md). Standalone mode is controlled using `Passengerfile.json` typically located in the *application root* for the app.
106+
107+
Use of this requires the `passenger` gem in [Ruby](Ruby.md).
108+
109+
```bash
110+
gem install passenger
111+
```
112+
113+
The following annotated configuration illustrates how it comes together. The *document root* is /var/www/forums/public while the *application root* is /var/www/forums.
114+
115+
See "[Configuration reference](https://www.phusionpassenger.com/library/config/standalone/reference/)" for a comprehensive listing of directives.
116+
117+
```json
118+
{
119+
/* Use rbenv shim loader, allows .ruby-version per-directory */
120+
"ruby": "/usr/local/share/ruby/rbenv/shims/ruby",
121+
/* can be node, wsgi, rack, or meteor */
122+
"app_type": "rack",
123+
"startup_file": "/var/www/forums/config.ru",
124+
"environment": "production",
125+
// Use Rack, bundled with Discourse as the HTTP server
126+
"engine": "builtin",
127+
// Statically set 6 workers at all times.
128+
"min_instances": 6,
129+
"max_pool_size": 6,
130+
"daemonize": true,
131+
"spawn_method": "smart",
132+
// Listen on 127.0.0.1:40011
133+
"address": "127.0.0.1",
134+
"port": 40011,
135+
// Necessary for reliable WebSocket operation in Ruby
136+
"force_max_concurrent_requests_per_process": 0,
137+
// Additional env variables to pass to Ruby at startup
138+
"envvars": {
139+
"RUBY_GC_HEAP_GROWTH_MAX_SLOTS": "40000",
140+
"RUBY_GC_HEAP_INIT_SLOTS": "400000",
141+
"RUBY_GC_HEAP_OLDOBJECT_LIMIT_FACTOR": "1.5",
142+
"LD_PRELOAD": "/usr/lib64/libjemalloc.so.1"
143+
}
144+
}
145+
```
146+
147+
Once configured it may be started using `passenger start` and stopped using `passenger stop`.
148+
72149
### See also
73150

74151
* [Configuration reference for Passenger + Apache](https://www.phusionpassenger.com/library/config/apache/reference) (phusionpassenger.com)

0 commit comments

Comments
 (0)