@genxis/n8nrockstars 1.0.0

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.
package/CHANGELOG.md ADDED
@@ -0,0 +1,33 @@
1
+ # Changelog
2
+
3
+ ## [1.0.0] - 2026-01-24
4
+
5
+ ### Added
6
+ - Initial release
7
+ - PostgreSQL 15 installation from official repo
8
+ - cPanel subdomain creation via UAPI
9
+ - DNS record management (direct zone file editing)
10
+ - Apache reverse proxy configuration (userdata paths)
11
+ - ModSecurity automatic disabling for n8n vhost
12
+ - FTP file upload automation
13
+ - n8n installation and startup
14
+ - Credential generation
15
+ - TLS certificate mismatch handling
16
+
17
+ ### Edge Cases Handled
18
+ - n8n v2 PostgreSQL-only requirement
19
+ - IPv6 binding issues (`N8N_LISTEN_ADDRESS=0.0.0.0`)
20
+ - cPanel Apache vhost generation quirks
21
+ - ModSecurity false positives
22
+ - SSL vs non-SSL vhost separation
23
+ - ZoneEdit module missing/broken
24
+ - FTP authentication
25
+
26
+ ### Known Limitations
27
+ - Requires SSH access OR WHM API for PostgreSQL installation
28
+ - Cannot fully automate if SSH port 22 blocked (manual PostgreSQL install required)
29
+ - AutoSSL certificate may take 5-10 minutes to provision
30
+
31
+ ---
32
+
33
+ **The Moat:** Every edge case listed above was discovered during actual deployment. Competitors will hit the same walls.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 GenXis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/PUBLISHING.md ADDED
@@ -0,0 +1,148 @@
1
+ # Publishing n8nROCKSTARS to npm
2
+
3
+ ## Package Ready ✅
4
+
5
+ **Package:** `@genxis/n8nrockstars`
6
+ **Version:** 1.0.0
7
+ **Organization:** GenXis (same as @genxis/whmrockstar)
8
+
9
+ ## What's Included
10
+
11
+ - ✅ CLI tool (`n8nrockstars`)
12
+ - ✅ Complete deployment automation
13
+ - ✅ PostgreSQL 15 installer
14
+ - ✅ Apache proxy configuration
15
+ - ✅ ModSecurity handling
16
+ - ✅ FTP file uploader
17
+ - ✅ All edge cases from 2-hour battle
18
+
19
+ ## Pre-Publish Checklist
20
+
21
+ - [x] Package.json complete
22
+ - [x] README.md with full documentation
23
+ - [x] LICENSE (MIT)
24
+ - [x] CHANGELOG.md
25
+ - [x] .npmignore configured
26
+ - [x] Git repository initialized
27
+ - [x] Initial commit made
28
+ - [ ] Test locally: `npm pack` then `npm install -g genxis-n8nrockstars-1.0.0.tgz`
29
+ - [ ] Create GitHub repo: genxis/n8nrockstars
30
+ - [ ] Push to GitHub
31
+ - [ ] npm login (GenXis organization)
32
+ - [ ] npm publish --access public
33
+
34
+ ## Publishing Steps
35
+
36
+ ### 1. Test Package Locally
37
+
38
+ ```bash
39
+ cd C:\Users\Administrator\Desktop\crazyvibe\n8nrockstars
40
+
41
+ # Create tarball
42
+ npm pack
43
+
44
+ # Install globally to test
45
+ npm install -g genxis-n8nrockstars-1.0.0.tgz
46
+
47
+ # Test CLI
48
+ n8nrockstars --help
49
+
50
+ # Uninstall test
51
+ npm uninstall -g @genxis/n8nrockstars
52
+ ```
53
+
54
+ ### 2. Create GitHub Repository
55
+
56
+ 1. Go to: https://github.com/new
57
+ 2. Repository name: `n8nrockstars`
58
+ 3. Organization: `genxis` (or your org)
59
+ 4. Description: "Deploy n8n self-hosted on cPanel/WHM servers"
60
+ 5. Public repository
61
+ 6. Create
62
+
63
+ ### 3. Push to GitHub
64
+
65
+ ```bash
66
+ git remote add origin https://github.com/genxis/n8nrockstars.git
67
+ git branch -M main
68
+ git push -u origin main
69
+ ```
70
+
71
+ ### 4. Publish to npm
72
+
73
+ ```bash
74
+ # Login to npm (if not already)
75
+ npm login
76
+
77
+ # Verify you're in GenXis org
78
+ npm whoami
79
+ npm org ls genxis
80
+
81
+ # Publish (scoped to @genxis org)
82
+ npm publish --access public
83
+ ```
84
+
85
+ ### 5. Verify Publication
86
+
87
+ ```bash
88
+ # Check npm page
89
+ https://www.npmjs.com/package/@genxis/n8nrockstars
90
+
91
+ # Test installation
92
+ npm install -g @genxis/n8nrockstars
93
+
94
+ # Test command
95
+ n8nrockstars --version
96
+ ```
97
+
98
+ ## Post-Publish
99
+
100
+ ### Update Package Description
101
+
102
+ On npm package page, add:
103
+ - Keywords: n8n, cpanel, whm, automation, deployment
104
+ - GitHub repo link
105
+ - Documentation link
106
+
107
+ ### Announce
108
+
109
+ - Post on npm
110
+ - GenXis website/blog
111
+ - n8n community forums
112
+ - Indie Hackers
113
+ - Reddit r/selfhosted
114
+ - Twitter/X
115
+
116
+ ### Tagline
117
+
118
+ **"Deploy n8n on cPanel in 5 minutes. We spent 2 hours finding the edge cases so you don't have to."**
119
+
120
+ ## The Moat
121
+
122
+ Every edge case in this package was discovered through actual pain:
123
+ 1. n8n v2 PostgreSQL requirement (not documented clearly)
124
+ 2. IPv6 binding on cPanel servers
125
+ 3. ModSecurity false positives
126
+ 4. Apache userdata paths for SSL/non-SSL
127
+ 5. ZoneEdit module missing
128
+ 6. TLS cert validation issues
129
+
130
+ **Competitors will hit the same walls. We already solved them.**
131
+
132
+ ## Maintenance
133
+
134
+ - Monitor GitHub issues for new edge cases
135
+ - Update when n8n changes requirements
136
+ - Add support for more cPanel configurations
137
+ - Consider adding Docker option as alternative
138
+
139
+ ## Revenue Potential
140
+
141
+ - Free tier: Basic deployment
142
+ - Pro tier: Includes monitoring, auto-updates, backups
143
+ - Enterprise: White-label, multi-server management
144
+ - Services: Managed n8n hosting on customer's cPanel
145
+
146
+ ---
147
+
148
+ **Ready to publish when you are!**
package/README.md ADDED
@@ -0,0 +1,276 @@
1
+ # n8nROCKSTARS 🎸
2
+
3
+ **Deploy n8n self-hosted on cPanel/WHM servers without losing your sanity.**
4
+
5
+ Battle-tested deployment automation that handles ALL the edge cases:
6
+ - ✅ n8n v2 requires PostgreSQL (not MySQL)
7
+ - ✅ IPv6 binding issues on cPanel servers
8
+ - ✅ ModSecurity blocking proxy requests
9
+ - ✅ Apache userdata paths for SSL + non-SSL vhosts
10
+ - ✅ DNS zone file editing (ZoneEdit module broken)
11
+ - ✅ TLS certificate mismatches
12
+ - ✅ FTP file uploads (UAPI multipart complexity)
13
+
14
+ ## Quick Start
15
+
16
+ ```bash
17
+ npx @genxis/n8nrockstars deploy \
18
+ --server your-server.com \
19
+ --user cpanel_username \
20
+ --domain yourdomain.com \
21
+ --subdomain n8n
22
+ ```
23
+
24
+ You'll be prompted for the cPanel password. The tool will:
25
+ 1. Install PostgreSQL 15 (from official repo)
26
+ 2. Create subdomain and DNS records
27
+ 3. Upload n8n configuration
28
+ 4. Install n8n via npm
29
+ 5. Configure Apache reverse proxy
30
+ 6. Disable ModSecurity for n8n
31
+ 7. Start n8n as persistent service
32
+ 8. Generate secure credentials
33
+
34
+ **Total time: ~5 minutes** (vs 2+ hours manually)
35
+
36
+ ## Installation
37
+
38
+ ```bash
39
+ npm install -g @genxis/n8nrockstars
40
+ ```
41
+
42
+ Or use without installing:
43
+
44
+ ```bash
45
+ npx @genxis/n8nrockstars deploy
46
+ ```
47
+
48
+ ## Requirements
49
+
50
+ **Server:**
51
+ - cPanel/WHM server (CentOS 7/8, AlmaLinux 8, Rocky Linux 8)
52
+ - Root/WHM access OR cPanel user access
53
+ - Minimum 2GB RAM, 5GB disk space
54
+ - Ports 80/443 accessible
55
+
56
+ **Credentials:**
57
+ - WHM API token (recommended) OR cPanel password
58
+ - FTP access for file uploads
59
+
60
+ ## Usage
61
+
62
+ ### Deploy n8n
63
+
64
+ ```bash
65
+ # Interactive mode
66
+ n8nrockstars deploy
67
+
68
+ # With options
69
+ n8nrockstars deploy \
70
+ --server your-server.com \
71
+ --user cpanel_user \
72
+ --whm-token YOUR_TOKEN \
73
+ --domain example.com \
74
+ --subdomain n8n
75
+ ```
76
+
77
+ ### Check Prerequisites
78
+
79
+ ```bash
80
+ n8nrockstars check \
81
+ --server your-server.com \
82
+ --user cpanel_user
83
+ ```
84
+
85
+ ## What Gets Installed
86
+
87
+ ```
88
+ /home/cpanel_user/n8n/
89
+ ├── server.js # n8n startup script
90
+ ├── node_modules/ # npm packages
91
+ │ └── n8n/ # n8n application
92
+ ├── .n8n/ # n8n data (auto-created)
93
+ │ ├── workflows/
94
+ │ └── credentials/
95
+ └── n8n.log # Application logs
96
+
97
+ PostgreSQL Database:
98
+ └── cpanel_user_n8n # n8n database
99
+
100
+ Apache Config:
101
+ ├── /usr/local/apache/conf/userdata/std/2_4/user/subdomain/proxy.conf
102
+ └── /usr/local/apache/conf/userdata/ssl/2_4/user/subdomain/proxy.conf
103
+ ```
104
+
105
+ ## Edge Cases Handled
106
+
107
+ ### 1. n8n v2 PostgreSQL Requirement
108
+
109
+ n8n dropped MySQL/MariaDB support. We automatically:
110
+ - Install PostgreSQL 15 from official repo (not CentOS default)
111
+ - Create database with correct encoding (UTF8)
112
+ - Grant schema permissions (GRANT ALL ON SCHEMA public)
113
+
114
+ ### 2. IPv6 Binding Issues
115
+
116
+ Many cPanel servers don't support IPv6. We set:
117
+ ```javascript
118
+ process.env.N8N_LISTEN_ADDRESS = '0.0.0.0';
119
+ ```
120
+
121
+ ### 3. ModSecurity False Positives
122
+
123
+ Apache's ModSecurity blocks proxy requests thinking they're attacks. We:
124
+ - Disable SecRuleEngine for n8n vhost
125
+ - Add to both HTTP and HTTPS vhosts
126
+
127
+ ### 4. Apache Proxy Configuration
128
+
129
+ cPanel's `/scripts/rebuildhttpdconf` overwrites manual Apache configs. We:
130
+ - Use userdata paths that survive rebuilds
131
+ - Configure both std (port 80) and ssl (port 443) vhosts
132
+ - Enable proxy modules in pre_main_global.conf
133
+
134
+ ### 5. TLS Certificate Mismatches
135
+
136
+ WHM servers often have self-signed certs or IP mismatches. We:
137
+ - Use `rejectUnauthorized: false` for all HTTPS connections
138
+ - Handle both WHM API (port 2087) and cPanel UAPI (port 2083)
139
+
140
+ ### 6. DNS ZoneEdit Module Broken
141
+
142
+ cPanel's ZoneEdit UAPI module is often missing/broken. We:
143
+ - Edit zone files directly (`/var/named/domain.db`)
144
+ - Run `/scripts/rebuilddnsconfig` to apply changes
145
+
146
+ ### 7. File Upload Complexity
147
+
148
+ UAPI file uploads require multipart encoding. We:
149
+ - Use FTP instead (simpler, more reliable)
150
+ - Create directories if missing
151
+ - Verify uploads
152
+
153
+ ## Configuration Options
154
+
155
+ ```javascript
156
+ {
157
+ server: 'your-server.com', // Server IP or hostname
158
+ user: 'cpanel_username', // cPanel user
159
+ password: 'cpanel_password', // cPanel password
160
+ whmToken: 'WHM_API_TOKEN', // Alternative to password
161
+ subdomain: 'n8n', // Subdomain for n8n
162
+ domain: 'example.com', // Main domain
163
+ skipPostgres: false, // Skip PostgreSQL install
164
+ skipSsl: false // Skip SSL certificate
165
+ }
166
+ ```
167
+
168
+ ## Troubleshooting
169
+
170
+ ### n8n fails to start
171
+
172
+ Check logs:
173
+ ```bash
174
+ tail -50 /home/cpanel_user/n8n/n8n.log
175
+ ```
176
+
177
+ Common issues:
178
+ - PostgreSQL not running: `systemctl start postgresql-15`
179
+ - Wrong database password in server.js
180
+ - Port 5678 already in use: `netstat -tulpn | grep 5678`
181
+
182
+ ### Apache shows parking page
183
+
184
+ Verify proxy config:
185
+ ```bash
186
+ grep -A5 "subdomain.domain.com" /etc/apache2/conf/httpd.conf
187
+ ls -la /usr/local/apache/conf/userdata/ssl/2_4/user/subdomain/
188
+ ```
189
+
190
+ Rebuild Apache:
191
+ ```bash
192
+ /scripts/rebuildhttpdconf
193
+ systemctl restart httpd
194
+ ```
195
+
196
+ ### ModSecurity blocking
197
+
198
+ Check logs:
199
+ ```bash
200
+ tail -50 /usr/local/apache/logs/error_log | grep -i modsec
201
+ ```
202
+
203
+ Disable for specific vhost:
204
+ ```bash
205
+ cat > /usr/local/apache/conf/userdata/ssl/2_4/user/subdomain/modsec.conf << 'EOF'
206
+ <IfModule mod_security2.c>
207
+ SecRuleEngine Off
208
+ </IfModule>
209
+ EOF
210
+ ```
211
+
212
+ ### PostgreSQL connection failed
213
+
214
+ Verify PostgreSQL is running:
215
+ ```bash
216
+ systemctl status postgresql-15
217
+ su - postgres -c "psql -d cpanel_user_n8n -c 'SELECT version();'"
218
+ ```
219
+
220
+ Check pg_hba.conf allows local connections:
221
+ ```bash
222
+ grep "local.*all" /var/lib/pgsql/15/data/pg_hba.conf
223
+ ```
224
+
225
+ ## The Story Behind This Tool
226
+
227
+ This tool was born from a **2-hour battle** deploying n8n on a cPanel server. Every edge case you can imagine:
228
+
229
+ - n8n v2 dropped MySQL support (no warning in docs)
230
+ - PostgreSQL 15 not in default CentOS repos
231
+ - Apache ignoring vhost configs
232
+ - ModSecurity blocking everything
233
+ - TLS cert validation failures
234
+ - IPv6 binding issues
235
+ - DNS zone editing nightmares
236
+
237
+ **If it took us 2 hours with root access and multiple AI assistants, imagine manual deployment.**
238
+
239
+ This tool packages ALL that pain into one command.
240
+
241
+ ## Why n8n on cPanel?
242
+
243
+ **vs Zapier/Make:**
244
+ - ✅ Unlimited workflows (Zapier charges per task)
245
+ - ✅ Self-hosted = $0 marginal cost
246
+ - ✅ Own your data and automation
247
+ - ✅ No vendor lock-in
248
+
249
+ **vs Cloud n8n:**
250
+ - ✅ $0/month (cloud n8n starts at $20/mo)
251
+ - ✅ No execution limits
252
+ - ✅ Full control over infrastructure
253
+
254
+ **vs Other Self-Hosted Options:**
255
+ - ✅ cPanel = familiar UI for non-technical users
256
+ - ✅ No Docker/Kubernetes complexity
257
+ - ✅ Runs alongside WordPress/existing sites
258
+
259
+ ## Contributing
260
+
261
+ Found another edge case? **Please** open an issue or PR.
262
+
263
+ This tool gets better every time someone deploys n8n on a weird cPanel configuration.
264
+
265
+ ## License
266
+
267
+ MIT
268
+
269
+ ## Support
270
+
271
+ - GitHub Issues: https://github.com/genxis/n8nrockstars/issues
272
+ - npm: https://www.npmjs.com/package/@genxis/n8nrockstars
273
+
274
+ ---
275
+
276
+ **Built by GenXis** - Tools that handle the nightmare edge cases so you don't have to.
package/bin/cli.js ADDED
@@ -0,0 +1,121 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * n8nROCKSTARS CLI
5
+ * Deploy n8n on cPanel/WHM without losing your sanity
6
+ */
7
+
8
+ const { program } = require('commander');
9
+ const chalk = require('chalk');
10
+ const inquirer = require('inquirer');
11
+ const { deployN8n } = require('../lib/deployer');
12
+ const { checkPrerequisites } = require('../lib/checker');
13
+
14
+ program
15
+ .name('n8nrockstars')
16
+ .description('Deploy n8n self-hosted on cPanel/WHM servers')
17
+ .version('1.0.0');
18
+
19
+ program
20
+ .command('deploy')
21
+ .description('Deploy n8n to a cPanel/WHM server')
22
+ .option('-s, --server <ip>', 'Server IP or hostname')
23
+ .option('-u, --user <username>', 'cPanel username')
24
+ .option('-p, --password <password>', 'cPanel password')
25
+ .option('--whm-token <token>', 'WHM API token (alternative to password)')
26
+ .option('--subdomain <name>', 'Subdomain for n8n', 'n8n')
27
+ .option('--domain <domain>', 'Main domain', 'example.com')
28
+ .option('--skip-postgres', 'Skip PostgreSQL installation (if already installed)')
29
+ .option('--skip-ssl', 'Skip SSL certificate installation')
30
+ .action(async (options) => {
31
+ console.log(chalk.cyan.bold('\n🎸 n8nROCKSTARS Deployment\n'));
32
+ console.log(chalk.gray('Handling all the cPanel/WHM nightmare edge cases...\n'));
33
+
34
+ // Interactive prompts if options not provided
35
+ if (!options.server) {
36
+ const answers = await inquirer.prompt([
37
+ {
38
+ type: 'input',
39
+ name: 'server',
40
+ message: 'Server IP or hostname:',
41
+ validate: (input) => input.length > 0 || 'Server is required'
42
+ },
43
+ {
44
+ type: 'input',
45
+ name: 'user',
46
+ message: 'cPanel username:',
47
+ validate: (input) => input.length > 0 || 'Username is required'
48
+ },
49
+ {
50
+ type: 'password',
51
+ name: 'password',
52
+ message: 'cPanel password:',
53
+ mask: '*'
54
+ },
55
+ {
56
+ type: 'input',
57
+ name: 'domain',
58
+ message: 'Main domain:',
59
+ default: 'example.com'
60
+ },
61
+ {
62
+ type: 'input',
63
+ name: 'subdomain',
64
+ message: 'Subdomain for n8n:',
65
+ default: 'n8n'
66
+ }
67
+ ]);
68
+ Object.assign(options, answers);
69
+ }
70
+
71
+ try {
72
+ // Check prerequisites
73
+ console.log(chalk.yellow('Checking server prerequisites...'));
74
+ await checkPrerequisites(options);
75
+
76
+ // Deploy
77
+ const result = await deployN8n(options);
78
+
79
+ console.log(chalk.green.bold('\n✅ DEPLOYMENT COMPLETE!\n'));
80
+ console.log(chalk.white('n8n URL:'), chalk.cyan.bold(result.url));
81
+ console.log(chalk.white('Username:'), chalk.cyan(result.username));
82
+ console.log(chalk.white('Password:'), chalk.yellow(result.password));
83
+ console.log(chalk.gray('\nCredentials saved to: n8n-credentials.txt\n'));
84
+
85
+ } catch (error) {
86
+ console.error(chalk.red.bold('\n❌ Deployment failed:\n'));
87
+ console.error(chalk.red(error.message));
88
+ console.error(chalk.gray('\nFor help: https://github.com/genxis/n8nrockstars/issues\n'));
89
+ process.exit(1);
90
+ }
91
+ });
92
+
93
+ program
94
+ .command('check')
95
+ .description('Check if server meets n8n requirements')
96
+ .option('-s, --server <ip>', 'Server IP')
97
+ .option('-u, --user <username>', 'cPanel username')
98
+ .option('-p, --password <password>', 'cPanel password')
99
+ .action(async (options) => {
100
+ try {
101
+ const results = await checkPrerequisites(options);
102
+ console.log(chalk.green('✅ Server ready for n8n deployment'));
103
+ } catch (error) {
104
+ console.error(chalk.red('❌ Prerequisites not met:'), error.message);
105
+ process.exit(1);
106
+ }
107
+ });
108
+
109
+ program
110
+ .command('uninstall')
111
+ .description('Remove n8n from cPanel server')
112
+ .option('-s, --server <ip>', 'Server IP')
113
+ .option('-u, --user <username>', 'cPanel username')
114
+ .option('--subdomain <name>', 'n8n subdomain', 'n8n')
115
+ .action(async (options) => {
116
+ console.log(chalk.yellow('Uninstalling n8n...'));
117
+ // TODO: Implement uninstall
118
+ console.log(chalk.red('Not implemented yet'));
119
+ });
120
+
121
+ program.parse();
package/index.js ADDED
@@ -0,0 +1,22 @@
1
+ /**
2
+ * n8nROCKSTARS - Main entry point
3
+ */
4
+
5
+ const { deployN8n } = require('./lib/deployer');
6
+ const { checkPrerequisites } = require('./lib/checker');
7
+ const { createSubdomain } = require('./lib/cpanel-subdomain');
8
+ const { configureApache } = require('./lib/apache-proxy');
9
+ const { installPostgreSQL } = require('./lib/postgres-installer');
10
+ const { startN8n, createSystemdService } = require('./lib/n8n-starter');
11
+ const { uploadFiles } = require('./lib/ftp-uploader');
12
+
13
+ module.exports = {
14
+ deployN8n,
15
+ checkPrerequisites,
16
+ createSubdomain,
17
+ configureApache,
18
+ installPostgreSQL,
19
+ startN8n,
20
+ createSystemdService,
21
+ uploadFiles
22
+ };
@@ -0,0 +1,65 @@
1
+ /**
2
+ * Apache proxy configuration for cPanel
3
+ * Survives /scripts/rebuildhttpdconf
4
+ */
5
+
6
+ const { executeSSH } = require('./ssh-executor');
7
+
8
+ async function configureApache(options) {
9
+ const { server, user, password, whmToken, subdomain } = options;
10
+
11
+ // Create userdata directories for both HTTP and HTTPS
12
+ const commands = [
13
+ // Create userdata directory for HTTP (port 80)
14
+ `mkdir -p /usr/local/apache/conf/userdata/std/2_4/${user}/${subdomain}`,
15
+
16
+ // Create userdata directory for HTTPS (port 443/SSL)
17
+ `mkdir -p /usr/local/apache/conf/userdata/ssl/2_4/${user}/${subdomain}`,
18
+
19
+ // HTTP proxy config
20
+ `cat > /usr/local/apache/conf/userdata/std/2_4/${user}/${subdomain}/proxy.conf << 'EOF'
21
+ <IfModule mod_security2.c>
22
+ SecRuleEngine Off
23
+ </IfModule>
24
+ ProxyPreserveHost On
25
+ ProxyPass / http://127.0.0.1:5678/
26
+ ProxyPassReverse / http://127.0.0.1:5678/
27
+ RequestHeader set X-Forwarded-Proto "http"
28
+ EOF`,
29
+
30
+ // HTTPS proxy config
31
+ `cat > /usr/local/apache/conf/userdata/ssl/2_4/${user}/${subdomain}/proxy.conf << 'EOF'
32
+ <IfModule mod_security2.c>
33
+ SecRuleEngine Off
34
+ </IfModule>
35
+ ProxyPreserveHost On
36
+ ProxyPass / http://127.0.0.1:5678/
37
+ ProxyPassReverse / http://127.0.0.1:5678/
38
+ RequestHeader set X-Forwarded-Proto "https"
39
+ RequestHeader set X-Forwarded-Port "443"
40
+ EOF`,
41
+
42
+ // Enable proxy modules in pre_main
43
+ `mkdir -p /etc/apache2/conf/includes`,
44
+
45
+ `cat > /etc/apache2/conf/includes/pre_main_global.conf << 'EOF'
46
+ LoadModule proxy_module modules/mod_proxy.so
47
+ LoadModule proxy_http_module modules/mod_proxy_http.so
48
+ LoadModule headers_module modules/mod_headers.so
49
+ EOF`,
50
+
51
+ // Rebuild Apache config (includes userdata)
52
+ '/scripts/rebuildhttpdconf',
53
+
54
+ // Restart Apache
55
+ 'systemctl restart httpd'
56
+ ];
57
+
58
+ for (const command of commands) {
59
+ await executeSSH({ server, user, password, whmToken, command });
60
+ }
61
+
62
+ return { status: 'configured' };
63
+ }
64
+
65
+ module.exports = { configureApache };