add "www + https" to subdomain in cyberpanle + openlitespeed - .htaccess

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

Related

CyberPanel OpenLiteSpeed: Host Node JS Website

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)

Caddy: unrecognized directive: uri

Caddy gives me this error:
run: adapting config using caddyfile: /etc/caddy/Caddyfile:21: unrecognized directive: uri
My Caddyfile:
{
email localemail#example.com
acme_ca https://acme-v02.api.letsencrypt.org/directory
#acme_ca https://acme-staging-v02.api.letsencrypt.org/directory
}
https://www.example.com {
file_server {
root /var/www/html
}
try_files {path}.html {path}
encode gzip zstd
log
}
example.com, altexample.com, www.altexample.com {
redir https://www.commerceowl.com{uri}
}
https://help.example.com {
uri /en/* strip_prefix /en
redir https://www.commerceowl.com/support{uri}
}
What's wrong with uri /en/* strip_prefix /en?
Version 2 official document (https://caddyserver.com/docs/caddyfile/directives/uri) describe like this:
uri strip_prefix /en

Bind9: limit query from subnet

I have a linux machine with a WiFi Hotspot assigning IP's in the 172.30.108.0/24 network.
I have bind 9 installed.
my named.conf only includes "include "/etc/bind/named.conf.local";", everything else is disabled.
My named.conf.local has:
options {
listen-on port 53 { 0.0.0.0; };
listen-on-v6 port 53 { ::1; };
directory "/var/cache/bind";
allow-query { localhost; };
recursion yes;
querylog yes;
};
acl clients {
172.30.108.0/24;
};
view "internal-view" {
match-clients { internal; };
allow-query { internal; };
allow-query-cache { internal; };
zone "limit.com." {
type master;
file "/etc/bind/db.limit.com";
};
# Mapping: Everything else to 127.0.0.1
zone "." {
type master;
file "/etc/bind/db.mapping";
};
};
view "external-view" {
match-clients { any; };
allow-query { any; };
allow-recursion { any; };
allow-query-cache { any; };
zone "wiincon.de." {
type master;
file "/etc/bind/db.limit.com";
};
include "/etc/bind/named.conf.default-zones";
};
My db.limit.com:
; BIND reverse data file for broadcast zone
;
$TTL 180
# IN SOA localhost. root.localhost. (
5 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
# IN NS localhost.
# IN A 192.168.5.5
www IN A 192.168.5.5
and finally my db.mapping:
; BIND reverse data file for broadcast zone
;
$TTL 3600
# IN SOA localhost. root.localhost. (
4 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
# IN NS localhost.
* IN A 127.0.0.1
My problem is now: the clients in 172.30.108.0/24 can query anything BUT www.limit.com
Actually: Clients from 172.30.108.0/24 should be able to resolve limit.com and www.limit.com, everything else should respond with 127.0.0.1.
When doing a nslookup I get
Non-authoraive answer:
*** can't find limit.com: no answer
I'm sure I'm missing something very obvious here. Any help is highly appreciated.
Found it. The problem was that the "SYSTEM" itself had 8.8.8.8 as the name server, hence bypassing everything local.

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;
}
}

Nginx redirect to external port

Have config looking something like this.
I now want the main entry to domain to be :80.
So its only nginx that can redirect to :3000 and :8081.
If the user types domain.com:3000 -> i want it to be redirected to domain.com:80.
Is that possible and still have the functionality below, whith redirection based on cookie?
map $cookie_version $mybackend {
default "127.0.0.1:3000";
"v1" "127.0.0.1:8080";
"v2" "127.0.0.1:3000";
}
...
location / {
proxy_pass http://$mybackend;
}
...
location ~ ^/(?<cver>v[12])/ {
...
add_header Set-Cookie "version=$cver;Domain=localhost;Path=/";
rewrite ^/v[12]/(.*)$ /$1 redirect;
}

Resources