@powerhousedao/ph-cli 2.5.0-dev.4 → 2.5.0-dev.6

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/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@powerhousedao/ph-cli",
3
- "version": "2.5.0-dev.4",
3
+ "version": "2.5.0-dev.6",
4
4
  "description": "",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
@@ -130,116 +130,43 @@ EOF
130
130
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
131
131
  read -p "Enter Connect domain (e.g. connect.google.com): " connect_domain
132
132
  read -p "Enter Switchboard domain (e.g. switchboard.google.com): " switchboard_domain
133
+ read -p "Enter admin email for Let's Encrypt notifications: " admin_email
133
134
 
134
135
  echo "Using domains:"
135
136
  echo "Connect: $connect_domain"
136
137
  echo "Switchboard: $switchboard_domain"
137
138
 
138
- # Generate temporary SSL certificates
139
- echo "Generating temporary SSL certificates..."
140
- sudo mkdir -p /etc/nginx/ssl
141
- sudo openssl req -x509 -nodes -days 1 -newkey rsa:2048 \
142
- -keyout /etc/nginx/ssl/temp.key \
143
- -out /etc/nginx/ssl/temp.crt \
144
- -subj "/CN=$connect_domain" \
145
- -addext "subjectAltName = DNS:$connect_domain,DNS:$switchboard_domain"
146
-
147
- # Check if Nginx configuration already exists
148
- if [ -f "/etc/nginx/sites-available/$PROJECT_NAME" ]; then
149
- echo "Nginx configuration for $PROJECT_NAME already exists"
150
- read -p "Do you want to overwrite it? (y/n): " overwrite_nginx
151
- if [ "$overwrite_nginx" != "y" ]; then
152
- echo "Keeping existing Nginx configuration"
153
- else
154
- # Create Nginx configuration for domains
155
- echo "Creating Nginx configuration..."
156
- sudo tee /etc/nginx/sites-available/$PROJECT_NAME > /dev/null << EOF
157
- # Security headers
158
- add_header Strict-Transport-Security "max-age=63072000" always;
159
- add_header X-Frame-Options DENY;
160
- add_header X-Content-Type-Options nosniff;
161
- add_header X-XSS-Protection "1; mode=block";
162
-
163
- # Compression settings
164
- brotli on;
165
- brotli_comp_level 6;
166
- brotli_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss;
167
- brotli_static on;
168
-
139
+ # Create initial Nginx configuration for certbot
140
+ echo "Creating initial Nginx configuration..."
141
+ sudo tee /etc/nginx/sites-available/$PROJECT_NAME > /dev/null << EOF
169
142
  server {
170
143
  listen 80;
171
144
  server_name $connect_domain $switchboard_domain;
172
- return 301 https://\$host\$request_uri;
173
- }
174
-
175
- server {
176
- listen 443 ssl http2;
177
- server_name $connect_domain;
178
-
179
- ssl_certificate /etc/nginx/ssl/temp.crt;
180
- ssl_certificate_key /etc/nginx/ssl/temp.key;
181
-
182
- # SSL configuration
183
- ssl_protocols TLSv1.2 TLSv1.3;
184
- ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
185
- ssl_prefer_server_ciphers off;
186
- ssl_session_timeout 1d;
187
- ssl_session_cache shared:SSL:50m;
188
- ssl_session_tickets off;
189
- ssl_stapling on;
190
- ssl_stapling_verify on;
191
-
192
- if (\$http_x_forwarded_proto = "http") {
193
- return 301 https://\$server_name\$request_uri;
194
- }
195
145
 
196
146
  location / {
197
- root $PWD/.ph/connect-build/dist;
147
+ root /var/www/html/$PROJECT_NAME;
198
148
  try_files \$uri \$uri/ /index.html;
199
- add_header Cache-Control "no-cache";
200
- add_header X-Forwarded-Proto \$scheme;
201
- add_header X-Forwarded-Host \$host;
202
- add_header X-Forwarded-Port \$server_port;
203
- }
204
- }
205
-
206
- server {
207
- listen 443 ssl http2;
208
- server_name $switchboard_domain;
209
-
210
- ssl_certificate /etc/nginx/ssl/temp.crt;
211
- ssl_certificate_key /etc/nginx/ssl/temp.key;
212
-
213
- location / {
214
- proxy_pass http://localhost:4001;
215
- proxy_http_version 1.1;
216
- proxy_set_header Upgrade \$http_upgrade;
217
- proxy_set_header Connection 'upgrade';
218
- proxy_set_header Host \$host;
219
- proxy_cache_bypass \$http_upgrade;
220
- proxy_set_header X-Real-IP \$remote_addr;
221
- proxy_set_header X-Forwarded-For \$proxy_add_x_forwarded_for;
222
- proxy_set_header X-Forwarded-Proto \$scheme;
223
149
  }
224
150
  }
225
151
  EOF
226
- fi
227
- else
228
- # Create Nginx configuration for domains
229
- echo "Creating Nginx configuration..."
230
- sudo tee /etc/nginx/sites-available/$PROJECT_NAME > /dev/null << EOF
231
- # Security headers
232
- add_header Strict-Transport-Security "max-age=63072000" always;
233
- add_header X-Frame-Options DENY;
234
- add_header X-Content-Type-Options nosniff;
235
- add_header X-XSS-Protection "1; mode=block";
236
152
 
237
- # Compression settings
238
- brotli on;
239
- brotli_comp_level 6;
240
- brotli_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss;
241
- brotli_static on;
153
+ # Enable the site
154
+ sudo ln -sf /etc/nginx/sites-available/$PROJECT_NAME /etc/nginx/sites-enabled/
155
+ sudo rm -f /etc/nginx/sites-enabled/default
156
+
157
+ # Test Nginx configuration
158
+ sudo nginx -t
159
+
160
+ # Restart Nginx to apply changes
161
+ sudo systemctl restart nginx
162
+
163
+ # Obtain SSL certificates
164
+ echo "Obtaining SSL certificates..."
165
+ sudo certbot --nginx -d $connect_domain -d $switchboard_domain --non-interactive --agree-tos --email $admin_email --redirect
242
166
 
167
+ # Update Nginx configuration with proper SSL settings
168
+ echo "Updating Nginx configuration with SSL settings..."
169
+ sudo tee /etc/nginx/sites-available/$PROJECT_NAME > /dev/null << EOF
243
170
  server {
244
171
  listen 80;
245
172
  server_name $connect_domain $switchboard_domain;
@@ -250,9 +177,6 @@ server {
250
177
  listen 443 ssl http2;
251
178
  server_name $connect_domain;
252
179
 
253
- ssl_certificate /etc/nginx/ssl/temp.crt;
254
- ssl_certificate_key /etc/nginx/ssl/temp.key;
255
-
256
180
  # SSL configuration
257
181
  ssl_protocols TLSv1.2 TLSv1.3;
258
182
  ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
@@ -262,6 +186,8 @@ server {
262
186
  ssl_session_tickets off;
263
187
  ssl_stapling on;
264
188
  ssl_stapling_verify on;
189
+ resolver 8.8.8.8 8.8.4.4 valid=300s;
190
+ resolver_timeout 5s;
265
191
 
266
192
  if (\$http_x_forwarded_proto = "http") {
267
193
  return 301 https://\$server_name\$request_uri;
@@ -281,8 +207,17 @@ server {
281
207
  listen 443 ssl http2;
282
208
  server_name $switchboard_domain;
283
209
 
284
- ssl_certificate /etc/nginx/ssl/temp.crt;
285
- ssl_certificate_key /etc/nginx/ssl/temp.key;
210
+ # SSL configuration
211
+ ssl_protocols TLSv1.2 TLSv1.3;
212
+ ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
213
+ ssl_prefer_server_ciphers off;
214
+ ssl_session_timeout 1d;
215
+ ssl_session_cache shared:SSL:50m;
216
+ ssl_session_tickets off;
217
+ ssl_stapling on;
218
+ ssl_stapling_verify on;
219
+ resolver 8.8.8.8 8.8.4.4 valid=300s;
220
+ resolver_timeout 5s;
286
221
 
287
222
  location / {
288
223
  proxy_pass http://localhost:4001;
@@ -297,21 +232,14 @@ server {
297
232
  }
298
233
  }
299
234
  EOF
300
- fi
301
235
 
302
- # Enable the site
303
- sudo ln -sf /etc/nginx/sites-available/$PROJECT_NAME /etc/nginx/sites-enabled/
304
- sudo rm -f /etc/nginx/sites-enabled/default
305
-
306
- # Test Nginx configuration
307
- sudo nginx -t
308
-
309
- # Obtain SSL certificates
310
- echo "Obtaining SSL certificates..."
311
- sudo certbot --nginx -d $connect_domain -d $switchboard_domain --non-interactive --agree-tos --email admin@$connect_domain
236
+ # Test and reload Nginx configuration
237
+ sudo nginx -t && sudo systemctl reload nginx
312
238
 
313
- # Remove temporary certificates
314
- sudo rm -f /etc/nginx/ssl/temp.*
239
+ # Set up automatic renewal
240
+ echo "Setting up automatic certificate renewal..."
241
+ sudo systemctl enable certbot.timer
242
+ sudo systemctl start certbot.timer
315
243
 
316
244
  else
317
245
  # Get machine hostname
@@ -328,18 +256,6 @@ EOF
328
256
  # Create Nginx configuration for self-signed
329
257
  echo "Creating Nginx configuration..."
330
258
  sudo tee /etc/nginx/sites-available/$PROJECT_NAME > /dev/null << EOF
331
- # Security headers
332
- add_header Strict-Transport-Security "max-age=63072000" always;
333
- add_header X-Frame-Options DENY;
334
- add_header X-Content-Type-Options nosniff;
335
- add_header X-XSS-Protection "1; mode=block";
336
-
337
- # Compression settings
338
- brotli on;
339
- brotli_comp_level 6;
340
- brotli_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss;
341
- brotli_static on;
342
-
343
259
  server {
344
260
  listen 80;
345
261
  server_name $hostname;
@@ -347,7 +263,8 @@ server {
347
263
  }
348
264
 
349
265
  server {
350
- listen 443 ssl http2;
266
+ listen 443 ssl;
267
+ http2 on;
351
268
  server_name $hostname;
352
269
 
353
270
  ssl_certificate /etc/ssl/certs/$hostname.crt;
@@ -392,6 +309,21 @@ EOF
392
309
  # =============================================================================
393
310
  pnpm prisma db push --schema node_modules/document-drive/dist/prisma/schema.prisma
394
311
 
312
+ # Add global security headers and compression settings to main nginx.conf
313
+ sudo tee -a /etc/nginx/nginx.conf > /dev/null << EOF
314
+
315
+ # Global security headers
316
+ add_header Strict-Transport-Security "max-age=63072000" always;
317
+ add_header X-Frame-Options DENY;
318
+ add_header X-Content-Type-Options nosniff;
319
+ add_header X-XSS-Protection "1; mode=block";
320
+
321
+ # Global compression settings
322
+ brotli_comp_level 6;
323
+ brotli_types text/plain text/css application/javascript application/json image/svg+xml application/xml+rss;
324
+ brotli_static on;
325
+ EOF
326
+
395
327
  echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
396
328
  echo " Environment setup complete!"
397
329
  echo " Use 'ph service start' to start services"
@@ -1,2 +1,2 @@
1
- export declare const version = "2.5.0-dev.4";
1
+ export declare const version = "2.5.0-dev.6";
2
2
  //# sourceMappingURL=version.d.ts.map
@@ -1,3 +1,3 @@
1
1
  // This file is auto-generated. DO NOT EDIT.
2
- export const version = "2.5.0-dev.4";
2
+ export const version = "2.5.0-dev.6";
3
3
  //# sourceMappingURL=version.js.map