CyberPanel OpenLiteSpeed: Host Node JS Website - node.js

I bought my own VPS and installed CyberPanel. Now I want to host my application written in NodeJS (Typescript).
So I have uploaded my application into public_html folder:
The application is resulted from these commands:
"build": "tsc --project ./&&copyFiles www/* build",
"build-deploy": "npm run build && cp package*.json build && cd build && npm install --only=production",
I use the build-deploy npm run command to include the node_modules folder as well. The problem is that my website cannot be accessed. It gives a timeout error, it keeps loading the page, then a timeout error shows up.
Request Timeout This request takes too long to process, it is timed
out by the server. If it should not be timed out, please contact
administrator of this web site to increase 'Connection Timeout'.
This is my vHost Conf:
docRoot $VH_ROOT/public_html
vhDomain $VH_NAME
vhAliases www.$VH_NAME
adminEmails xxxxxx#gmail.com
enableGzip 1
enableIpGeo 1
index {
useServer 0
indexFiles index.php, index.html
}
errorlog $VH_ROOT/logs/$VH_NAME.error_log {
useServer 0
logLevel WARN
rollingSize 10M
}
accesslog $VH_ROOT/logs/$VH_NAME.access_log {
useServer 0
logFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i""
logHeaders 5
rollingSize 10M
keepDays 10
compressArchive 1
}
scripthandler {
add lsapi:apidi5248 php
}
extprocessor apidi5248 {
type lsapi
address UDS://tmp/lshttpd/apidi5248.sock
maxConns 10
env LSAPI_CHILDREN=10
initTimeout 600
retryTimeout 0
persistConn 1
pcKeepAliveTimeout 1
respBuffer 0
autoStart 1
path /usr/local/lsws/lsphp81/bin/lsphp
extUser apidi5248
extGroup apidi5248
memSoftLimit 2047M
memHardLimit 2047M
procSoftLimit 400
procHardLimit 500
}
phpIniOverride {
}
module cache {
storagePath /usr/local/lsws/cachedata/$VH_NAME
}
rewrite {
enable 1
autoLoadHtaccess 1
}
context /.well-known/acme-challenge {
location /usr/local/lsws/Example/html/.well-known/acme-challenge
allowBrowse 1
rewrite {
}
addDefaultCharset off
phpIniOverride {
}
}
vhssl {
keyFile /etc/letsencrypt/live/api.digilifesoftware.com/privkey.pem
certFile /etc/letsencrypt/live/api.digilifesoftware.com/fullchain.pem
certChain 1
sslProtocol 24
enableECDHE 1
renegProtection 1
sslSessionCache 1
enableSpdy 15
enableStapling 1
ocspRespMaxAge 86400
}
context / {
type appserver
location $VH_ROOT/public_html
startupFile server.js
binPath /usr/bin/node
appType node
maxConns 100
accessControl {
allow *
}
rewrite {
}
addDefaultCharset off
}
Please help

Check this file /usr/local/lsws/logs/stderr.log. It's node errors log, maybe you`ll find something useful)

Related

Waypoint deployment through nomad getting errors HTTP: no host in request URL

I'm currently building an app by using react where I build a docker container to help with the deployment through Waypoint and Nomad. However, I'm currently getting the following issue:
! Put "http:///v1/jobs/parse": http: no Host in request URL
My docker file look like this:
FROM node:16
# Set the working directory to /app
WORKDIR /app
# Copy the package.json and package-lock.json files to the container
COPY package*.json ./
# Install the dependencies
RUN npm install
# Copy the rest of the application code to the container
COPY . .
# Expose port
EXPOSE 3000
# Specify the command to run the application
CMD [ "npm", "run", "start" ]
This is my nomad configuration file:
#example.nomad.tpl
job "web" {
datacenters = ["dc1"]
group "app" {
update {
max_parallel = 1
canary = 1
auto_revert = true
auto_promote = false
health_check = "task_states"
}
task "app" {
driver = "docker"
config {
image = "${artifact.image}:${artifact.tag}"
}
env {
%{ for k,v in entrypoint.env ~}
${k} = "${v}"
%{ endfor ~}
// For URL service
PORT = "3000"
}
}
}
}
This is my waypoint.hcl config file:
# Copyright (c) HashiCorp, Inc.
# SPDX-License-Identifier: MPL-2.0
project = "nomad-jobspec-nodejs"
app "nodejs-jobspec-web" {
build {
use "pack" {}
registry {
use "docker" {
image = "hvaandres/my-app-nomad"
tag = "latest"
local = true
}
}
}
deploy {
use "nomad-jobspec" {
// Templated to perhaps bring in the artifact from a previous
// build/registry, entrypoint env vars, etc.
jobspec = templatefile("${path.app}/example.nomad.tpl")
}
}
release {
use "nomad-jobspec-canary" {
groups = [
"app"
]
fail_deployment = false
}
}
}
I'm new to this tool and I wonder if anyone can redirect me in the right direction on how to solve this problem.

add "www + https" to subdomain in cyberpanle + openlitespeed

I'm using the Cyberpanel for my web control panel. my web server is Open-litespeed.
https://community.cyberpanel.net/t/01-installing-cyberpanel/82
Last night I add subdomain and it's totally work fine but the question is how add "www + https" in my subdmoain ?
There is an option in crating domain and subdomains for SSL and can be activate it.
For main domain , I choese the WWW and https.
let see how my domain is open : https://www.avadminsite.io/
I add the staticcdn for my subdomain and I expect it open like this : https://www.staticcdn.avadminsite.io/
now it's working like this: https://staticcds.avadminsite.io/
The cyberpanel has vhost configuration
vhost config for domain:
docRoot $VH_ROOT/public_html
vhDomain $VH_NAME
vhAliases www.$VH_NAME
adminEmails it is my emain section
enableGzip 1
enableIpGeo 1
index {
useServer 0
indexFiles index.php, index.html
}
errorlog $VH_ROOT/logs/$VH_NAME.error_log {
useServer 0
logLevel WARN
rollingSize 10M
}
accesslog $VH_ROOT/logs/$VH_NAME.access_log {
useServer 0
logFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i""
logHeaders 5
rollingSize 10M
keepDays 10
compressArchive 1
}
errorpage 403 {
url 403.html
}
errorpage 404 {
url 404.html
}
errorpage 500 {
url 500.html
}
scripthandler {
add lsapi:avadminsite1267 php
}
extprocessor avadminsite1267 {
type lsapi
address UDS://tmp/lshttpd/avadminsite1267.sock
maxConns 10
env LSAPI_CHILDREN=10
initTimeout 600
retryTimeout 0
persistConn 1
pcKeepAliveTimeout 1
respBuffer 0
autoStart 1
path /usr/local/lsws/lsphp80/bin/lsphp
extUser avadminsite1267
extGroup avadminsite1267
memSoftLimit 2047M
memHardLimit 2047M
procSoftLimit 400
procHardLimit 500
}
phpIniOverride {
php_admin_value open_basedir "/tmp:$VH_ROOT"
}
module cache {
storagePath /usr/local/lsws/cachedata/$VH_NAME
}
rewrite {
enable 1
autoLoadHtaccess 1
}
context /.well-known/acme-challenge {
location /usr/local/lsws/Example/html/.well-known/acme-challenge
allowBrowse 1
rewrite {
}
addDefaultCharset off
phpIniOverride {
}
}
vhssl {
keyFile /etc/letsencrypt/live/icf.ir/privkey.pem
certFile /etc/letsencrypt/live/icf.ir/fullchain.pem
certChain 1
sslProtocol 24
enableECDHE 1
renegProtection 1
sslSessionCache 1
enableSpdy 15
enableStapling 1
ocspRespMaxAge 86400
}
Also the cyberpanel has vhost configuration for subdomains too
docRoot /home/avadminsite.io/staticcdn.avadminsite.io
vhDomain $VH_NAME
vhAliases www.$VH_NAME
adminEmails myemail#mail.com
enableGzip 1
enableIpGeo 1
index {
useServer 0
indexFiles index.php, index.html
}
errorlog $VH_ROOT/logs/avadminsite.io.error_log {
useServer 0
logLevel WARN
rollingSize 10M
}
accesslog $VH_ROOT/logs/avadminsite.io.access_log {
useServer 0
logFormat "%h %l %u %t "%r" %>s %b "%{Referer}i" "%{User-Agent}i""
logHeaders 5
rollingSize 10M
keepDays 10
compressArchive 1
}
phpIniOverride {
}
module cache {
storagePath /usr/local/lsws/cachedata/$VH_NAME
}
errorpage 403 {
url 403.html
}
errorpage 404 {
url 404.html
}
errorpage 500 {
url 500.html
}
scripthandler {
add lsapi:avadminsite12677235 php
}
extprocessor avadminsite12677235 {
type lsapi
address UDS://tmp/lshttpd/avadminsite12677235.sock
maxConns 10
env LSAPI_CHILDREN=10
initTimeout 60
retryTimeout 0
persistConn 1
pcKeepAliveTimeout 1
respBuffer 0
autoStart 1
path /usr/local/lsws/lsphp72/bin/lsphp
extUser icfir1267
extGroup icfir1267
memSoftLimit 2047M
memHardLimit 2047M
procSoftLimit 400
procHardLimit 500
}
rewrite {
enable 1
autoLoadHtaccess 1
}
context /.well-known/acme-challenge {
location /usr/local/lsws/Example/html/.well-known/acme-challenge
allowBrowse 1
rewrite {
}
addDefaultCharset off
phpIniOverride {
}
}
Please help.
Warm Regards,
I have try to add: www.cloudlinux.wadetest.club to cyberpanel
add the A record to your DNS:
add_DNS_record
Could you navigate to cyberpanel dashboard: https://YOUR_IP:8090
Main -> Create Website
create_website
then it will works
result

Can't start laravel-echo-server with supervisor

I have already referenced all of the other suggestions that people have made on other posts, nothing has worked.
Paths to Relevant Files
The root directory of my project is /var/www/html and that is where I have .env and laravel-echo-server.json.
I have laravel-echo-server installed globally. I can run it successfully from a with laravel-echo-server start --dir=/path/to/project/root
When I run which laravel-echo-server, it shows its path is ~/.nvm/versions/node/v13.5.0/bin/laravel-echo-server.
Likewise, the path for node is ~/.nvm/versions/node/v13.5.0/bin/node
My conf file for the supervisor worker is at /etc/supervisor/conf.d/laravel-echo-server.conf.
Supervisor runs the other workers successfully, such as Horizon, so it is not a problem with the supervisor configuration.
Conf File
[program:laravel-echo-server]
process_name=%(program_name)s_%(process_num)02d
command=laravel-echo-server start --dir=/var/www/html
autostart=true
numprocs=1
user=root
autorestart=true
stdout_logfile=/var/log/workers/laravel-echo-server.log
I have also tried the following variations for the command line:
command=/usr/bin/laravel-echo-server start --dir=/var/www/html
command=~/.nvm/versions/node/v13.5.0/bin/laravel-echo-server --dir=/var/www/html
All of these attempts and variations return ERROR (no such file).
I also tried making duplicate copies of laravel-echo-server.json to place in locations like /usr/bin and /etc/supervisor/conf.d but that didn't help.
I also tried changing the user from root to ec2-user (which is my username with which I can successfully initialize laravel-echo-server from the command line).
I have also tried adding another line: directory=/var/www/html but that doesn't help.
Shell Executable Attempt
I tried to make a shell executable file that supervisor could call. Here is the file:
#!/bin/bash
exec laravel-echo-server start --dir=../../../var/www/html
I called the executable with supervisor like this:
command=bash -c laravel-echo-server.sh
But it returned ERROR (spawn error).
Additional Info
supervisord.conf
[inet_http_server]
port=*:9001
[unix_http_server]
file=/var/run/supervisor.sock ; (the path to the socket file)
chmod=0700 ; sockef file mode (default 0700)
[rpcinterface:supervisor]
supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
[supervisord]
;http_port=/var/tmp/supervisor.sock ; (default is to run a UNIX domain socket server)
;http_port=127.0.0.1:9001 ; (alternately, ip_address:port specifies AF_INET)
;sockchmod=0700 ; AF_UNIX socketmode (AF_INET ignore, default 0700)
;sockchown=nobody.nogroup ; AF_UNIX socket uid.gid owner (AF_INET ignores)
;umask=022 ; (process file creation umask;default 022)
logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
logfile_maxbytes=50MB ; (max main logfile bytes b4 rotation;default 50MB)
logfile_backups=10 ; (num of main logfile rotation backups;default 10)
loglevel=info ; (logging level;default info; others: debug,warn)
pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
nodaemon=false ; (start in foreground if true;default false)
minfds=1024 ; (min. avail startup file descriptors;default 1024)
minprocs=200 ; (min. avail process descriptors;default 200)
;nocleanup=true ; (don't clean up tempfiles at start;default false)
;http_username=user ; (default is no username (open system))
;http_password=123 ; (default is no password (open system))
;childlogdir=/tmp ; ('AUTO' child log dir, default $TEMP)
;user=chrism ; (default is current user, required if root)
;directory=/tmp ; (default is not to cd during start)
;environment=KEY=value ; (key value pairs to add to environment)
[supervisorctl]
serverurl=unix:///var/run/supervisor.sock
;serverurl=http://127.0.0.1:9001 ; use an http:// url to specify an inet socket
;username=chris ; should be same as http_username if set
;password=123 ; should be same as http_password if set
;prompt=mysupervisor ; cmd line prompt (default "supervisor")
[include]
files = /etc/supervisor/conf.d/*.conf
laravel-echo-server.json
{
"authHost": http://mywebsite.com,
"authEndpoint": "/broadcasting/auth",
"clients": [],
"database": "redis",
"databaseConfig": {
"redis": {[my redis credentials]},
"sqlite": {
"databasePath": "/database/laravel-echo-server.sqlite"
}
},
"devMode": true,
"host": null,
"port": "6001",
"protocol": "http",
"socketio": {},
"sslCertPath": "",
"sslKeyPath": "",
"sslCertChainPath": "",
"sslPassphrase": "",
"subscribers": {
"http": true,
"redis": true
},
"apiOriginAllow": {
"allowCors": false,
"allowOrigin": "",
"allowMethods": "",
"allowHeaders": ""
}
}
UPDATE
Now I have tried:
command=/home/ec2-user/.nvm/versions/node/v13.5.0/bin/laravel-echo-server start --dir=/var/www/html
per the suggestion in the post comments. However that is returning ERROR (spawn error)
When I check the supervisord.log, it shows the following:
2019-12-31 07:27:05,869 INFO exited: laravel-echo-server_00 (exit status 127; not expected)
Exit status code 127 apparently means "command not found".
So after giving up on running it with composer, it became easiest to run it with pm2.
Here is my .ebextensions command:
sudo yum install -y gcc-c++ make
curl -sL https://rpm.nodesource.com/setup_13.x | sudo -E bash -
sudo yum install -y nodejs
npm config set scripts-prepend-node-path true
npm install -g laravel-echo-server
npm install -g pm2#latest
pm2 start laravel-echo-server-pm2.json
And my pm2 json:
{
"name": "laravel-echo-server",
"script": "laravel-echo-server",
"args": "start"
}
I also added a few more commands to .ebextensions that allow me to modify my .env file. The changes overwrite the values written into laravel-echo-server.json. This way, I don't have to change them every time I switch from dev to prod:
echo "LARAVEL_ECHO_SERVER_REDIS_HOST=production-redis-host.com" >> .env
echo "LARAVEL_ECHO_SERVER_REDIS_PORT=6379" >> .env
echo "LARAVEL_ECHO_SERVER_DEBUG=false" >> .env

Setting up nginx with multiple IPs

I have my nginx configuration file under /etc/nginx/sites-available/ with two upstreams say
upstream test1 {
server 1.1.1.1:50;
server 1.1.1.2:50;
}
upstream test2 {
server 2.2.2.1:60;
server 2.2.2.2:60;
}
server {
location / {
proxy_pass http://test1;
}
location / {
proxy_pass http://test2;
}
}
Sending a curl request to <PrimaryIP>:80 works but I want to use <SecondaryIP1>:80 for test1 and <SecondaryIP2>:80 for test2. Is it possible to define this in nginx?
You have to have two server directives to accomplish this task:
upstream test1 {
server 1.1.1.1:50;
server 1.1.1.2:50;
}
upstream test2 {
server 2.2.2.1:60;
server 2.2.2.2:60;
}
server {
listen 80
server_name <SecondartIP1>
location / {
proxy_pass http://test1;
}
}
server {
listen 80
server_name <SecondarIP2>
location / {
proxy_pass http://test2;
}
}

Trouble with VisualEditor in mediawiki

Hi I've installed mediawiki 1.26.2 with the extensión Visual Editor, nodejs and parsoid, the question is that when I start parsoid, it seems every process is working right but the the configuration of parsoid and visualeditor, I can't see any editor in my wiki.
I describe below all my configurations, how I start parsoid, the processes of parsoid involved and the configurations lines in localsettings of media wiki configuration file.
/etc/init.d/parsoid2 start-end script:
#!/bin/bash
#
# chkconfig: 35 90 12
# description: Foo server
#
# Get function from functions library
#. /etc/init.d/functions
# Start the service PARSOID
SCRIPT_PATH="/usr/lib/parsoid/src/bin/server.js"
DAEMON="/usr/bin/node $SCRIPT_PATH"
DAEMON_ARGS=""
start() {
#initlog -c "echo -n Starting PARSOID server: "
ulimit -n 64000
/usr/bin/node /usr/lib/parsoid/src/bin/server.js >> /var/log/parsoid/parsoid.log 2>&1 &
### Create the lock file ###
#touch /var/lock/subsys/parsoid
success $"PARSOID server startup"
echo
}
# Restart the service PARSOID
stop() {
#initlog -c "echo -n Stopping PARSOID server: "
pkill -f server.js
### Now, delete the lock file ###
rm -f /var/lock/subsys/parsoid
echo
}
### main logic ###
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status parsoid_nodejs.sh
;;
restart|reload|condrestart)
stop
start
;;
*)
echo $"Usage: $0 {start|stop|restart|reload|status}"
exit 1
esac
exit 0
processes of parsoid involved after I run /etc/init.d/parsoid2 start
root#vscj016mlinuxserver:~# ps -ef | grep parsoid
root 2244 1 0 08:21 pts/0 00:00:00 /usr/bin/node /usr/lib/parsoid/src/bin/server.js
root 2251 2244 0 08:21 pts/0 00:00:00 /usr/bin/nodejs /usr/lib/parsoid/src/bin/server.js
root 2252 2244 0 08:21 pts/0 00:00:00 /usr/bin/nodejs /usr/lib/parsoid/src/bin/server.js
root 2258 2244 0 08:21 pts/0 00:00:00 /usr/bin/nodejs /usr/lib/parsoid/src/bin/server.js
root 2264 2244 0 08:21 pts/0 00:00:00 /usr/bin/nodejs /usr/lib/parsoid/src/bin/server.js
root 2437 2023 0 08:36 pts/0 00:00:00 grep --color=auto parsoid
root#vscj016mlinuxserver:~#
the Localsetting.js parsoid configuration file:
exports.setup = function(parsoidConfig) {
// Set your own user-agent string
// Otherwise, defaults to "Parsoid/<current-version-defined-in- package.json>"
//parsoidConfig.userAgent = "My-User-Agent-String";
// Configure Parsoid to point to your MediaWiki instance.
parsoidConfig.setMwApi({
// The "prefix" is the name given to this wiki configuration in the
// (deprecated) Parsoid v1 API.
prefix: 'localhost', // optional
// The "domain" is used for communication with Visual Editor
// and RESTBase. It defaults to the hostname portion of
// the `uri` property below, but you can manually set it
// to an arbitrary string.
domain: 'localhost', // optional
// This is the only required parameter:
// the URL of you MediaWiki API endpoint.
uri: 'http://localhost/mediawiki/api.php',
// To specify a proxy (or proxy headers) specific to this prefix
// (which overrides defaultAPIProxyURI). Alternatively, set `proxy`
// to `null` to override and force no proxying when a default proxy
// has been set.
/*
proxy: {
uri: 'http://my.proxy:1234/',
headers: { 'X-Forwarded-Proto': 'https' } // headers are optional
}
*/
});
The configuration for VisualEditor at /var/www/HTML/mediawiki/Localsettings.php:
require_once "$IP/extensions/VisualEditor/VisualEditor.php";
wfLoadExtension ( 'VisualEditor' );
$wgDefaultUserOptions['visualeditor-enable'] = 1;
$wgDefaultUserOptions['minordefault'] = 1;
$wgHiddenPrefs[] = 'visualeditor-enable';
$wgVisualEditorParsoidURL = 'http://localhost:8000';
$wgVirtualRestConfig['modules']['parsoid'] = array('url' => 'http://localhost:8000', 'domain' => 'localhost', 'prefix' => 'localhost');
$wgSessionsInObjectCache = true;
$wgVirtualRestConfig['modules']['parsoid']['forwardCookies'] = true;
Please ensure that your parsoid version match your Visual Editor version, there is a chance that you should use old-way to configure Visual Editor:
$wgVisualEditorParsoidURL = 'http://127.0.0.1:8000';
$wgVisualEditorParsoidPrefix = 'localhost';
If you see the button "Edit source" on your pages only, make sure the Visual Editor is enabled for some name spaces in `LocalSettings.phpExample:
$wgVisualEditorNamespaces = array(NS_MAIN, NS_USER);
Source: https://www.mediawiki.org/wiki/Extension:VisualEditor#Complete_list_of_configuration_options
Check if Visual Editor is enabled in the User Preferences and you see the enabled name spaces as well

Resources