apache-node-proxy
Version:
CLI tool to automatically configure Apache virtual hosts for Node.js applications
62 lines โข 3.08 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const chalk_1 = __importDefault(require("chalk"));
const fs_extra_1 = __importDefault(require("fs-extra"));
const path_1 = __importDefault(require("path"));
console.log(chalk_1.default.blue.bold('๐งช Testing Apache Node.js Proxy'));
console.log(chalk_1.default.gray('Running in test mode - no actual configuration will be applied\n'));
// Test configuration generation
const testOptions = {
projectPath: '/opt/bitnami/projects/testapp',
port: 3000,
appName: 'testapp',
useHttps: true,
usePredefined: false
};
// Generate test configurations
const httpConfig = `<VirtualHost _default_:80>
ServerAlias *
DocumentRoot "${testOptions.projectPath}/public"
<Directory "${testOptions.projectPath}/public">
Require all granted
</Directory>
ProxyPass / http://localhost:${testOptions.port}/
ProxyPassReverse / http://localhost:${testOptions.port}/
</VirtualHost>`;
const httpsConfig = `<VirtualHost _default_:443>
ServerAlias *
SSLEngine on
SSLCertificateFile "/opt/bitnami/apache/conf/bitnami/certs/server.crt"
SSLCertificateKeyFile "/opt/bitnami/apache/conf/bitnami/certs/server.key"
DocumentRoot "${testOptions.projectPath}"
<Directory "${testOptions.projectPath}">
Require all granted
</Directory>
ProxyPass / http://localhost:${testOptions.port}/
ProxyPassReverse / http://localhost:${testOptions.port}/
</VirtualHost>`;
// Create test output directory
const testDir = path_1.default.join(__dirname, '../test-output');
fs_extra_1.default.ensureDirSync(testDir);
// Write test configurations
const httpConfigPath = path_1.default.join(testDir, `${testOptions.appName}-http-vhost.conf`);
const httpsConfigPath = path_1.default.join(testDir, `${testOptions.appName}-https-vhost.conf`);
fs_extra_1.default.writeFileSync(httpConfigPath, httpConfig);
fs_extra_1.default.writeFileSync(httpsConfigPath, httpsConfig);
console.log(chalk_1.default.green('โ
Test configurations generated successfully!'));
console.log(chalk_1.default.white(` HTTP config: ${httpConfigPath}`));
console.log(chalk_1.default.white(` HTTPS config: ${httpsConfigPath}`));
console.log(chalk_1.default.blue.bold('\n๐ Generated HTTP Configuration:'));
console.log(chalk_1.default.gray(httpConfig));
console.log(chalk_1.default.blue.bold('\n๐ Generated HTTPS Configuration:'));
console.log(chalk_1.default.gray(httpsConfig));
console.log(chalk_1.default.yellow('\n๐ก To test with actual Apache:'));
console.log(chalk_1.default.white(' 1. Copy the generated configs to /opt/bitnami/apache/conf/vhosts/'));
console.log(chalk_1.default.white(' 2. Restart Apache: sudo /opt/bitnami/ctlscript.sh restart apache'));
console.log(chalk_1.default.white(' 3. Ensure your Node.js app is running on port 3000'));
console.log(chalk_1.default.green.bold('\nโ
Test completed successfully!'));
//# sourceMappingURL=test.js.map