Custom http.conf for subdomains - apache

I tried all the ways I knew, But...
Let me explain with an example what I want.
I have a blog service, with main domain and many domain pointers and subdomains.
Main domain: blog.com
Subdomains: sub1.blog.com, sub2.blog.com, sub3.blog.com and....
Domain pointers : domain1.com , domain2.com, domain3.com and...
Every domain redirect to a spacial subdomain with Php code
But, what is the problem?
When i add a Subdomain (for exapmle sub2.blog.com) to Sub Domains, in user httpd.conf create VirtualHost settings for All domain pointers (sub2.domain1.com, sub2.domain2.com, sub2.domain3.com and...) ... But i don't want it!!!
And what is the big problem ???
for example if i had 600 domain pointer, with create 500 subdomains, httpd add 3000000 (500x600) VirtualHost settings to user httpd.conf file. and httpd.conf file size will be very large.
What will be the result?
A big time needed to create httpd.conf file
Server load coming to very High
Apache server Crash
And...
I want Subdomain VirtualHost just create for Main Domain (sub2.blog.com) , not for Domain Pointers... I don't need sub2.domain1.com or others...
What can i do for this ? Help me Guys
Can I change rewrite_confs script to do what i want it?
Or any way....???
Here the VirtualHost settings that happened to me:(
<VirtualHost 88.88.88.88:80 >
ServerName www.sub1.domain1.com
ServerAlias www.sub1.domain1.com sub1.domain1.com
ServerAdmin webmaster#blog.com
DocumentRoot /home/blog/domains/blog.com/public_html/sub1
UseCanonicalName OFF
<IfModule !mod_ruid2.c>
SuexecUserGroup blog blog
</IfModule>
CustomLog /var/log/httpd/domains/blog.com.sub1.bytes bytes
CustomLog /var/log/httpd/domains/blog.com.sub1.log combined
ErrorLog /var/log/httpd/domains/blog.com.sub1.error.log
<Directory /home/blog/domains/blog.com/public_html/sub1>
AllowOverride AuthConfig FileInfo Indexes Limit Options=Indexes,IncludesNOEXEC,MultiViews,SymLinksIfOwnerMatch,FollowSymLinks,None
Options -ExecCGI -Includes +IncludesNOEXEC
<FilesMatch "\.(inc|php|phtml|phps|php56)$">
<If "-f %{REQUEST_FILENAME}">
#ProxyErrorOverride on
AddHandler "proxy:unix:/usr/local/php56/sockets/blog.sock|fcgi://localhost" .inc .php .phtml .php56
</If>
</FilesMatch>
</Directory>
</VirtualHost>
<VirtualHost 88.88.88.88:80 >
ServerName www.sub1.domain2.com
ServerAlias www.sub1.domain2.com news.domain2.com
ServerAdmin webmaster#blog.com
DocumentRoot /home/blog/domains/blog.com/public_html/sub1
UseCanonicalName OFF
<IfModule !mod_ruid2.c>
SuexecUserGroup blog blog
</IfModule>
CustomLog /var/log/httpd/domains/blog.com.sub1.bytes bytes
CustomLog /var/log/httpd/domains/blog.com.sub1.log combined
ErrorLog /var/log/httpd/domains/blog.com.sub1.error.log
<Directory /home/blog/domains/blog.com/public_html/sub1>
AllowOverride AuthConfig FileInfo Indexes Limit Options=Indexes,IncludesNOEXEC,MultiViews,SymLinksIfOwnerMatch,FollowSymLinks,None
Options -ExecCGI -Includes +IncludesNOEXEC
<FilesMatch "\.(inc|php|phtml|phps|php56)$">
<If "-f %{REQUEST_FILENAME}">
#ProxyErrorOverride on
AddHandler "proxy:unix:/usr/local/php56/sockets/blog.sock|fcgi://localhost" .inc .php .phtml .php56
</If>
</FilesMatch>
</Directory>
</VirtualHost>
<VirtualHost 88.88.88.88:80 >
ServerName www.sub1.domain3.com
ServerAlias www.sub1.domain3.com sub1.domain3.com
ServerAdmin webmaster#blog.com
DocumentRoot /home/blog/domains/blog.com/public_html/sub1
UseCanonicalName OFF
<IfModule !mod_ruid2.c>
SuexecUserGroup blog blog
</IfModule>
CustomLog /var/log/httpd/domains/blog.com.sub1.bytes bytes
CustomLog /var/log/httpd/domains/blog.com.sub1.log combined
ErrorLog /var/log/httpd/domains/blog.com.sub1.error.log
<Directory /home/blog/domains/blog.com/public_html/sub1>
AllowOverride AuthConfig FileInfo Indexes Limit Options=Indexes,IncludesNOEXEC,MultiViews,SymLinksIfOwnerMatch,FollowSymLinks,None
Options -ExecCGI -Includes +IncludesNOEXEC
<FilesMatch "\.(inc|php|phtml|phps|php56)$">
<If "-f %{REQUEST_FILENAME}">
#ProxyErrorOverride on
AddHandler "proxy:unix:/usr/local/php56/sockets/blog.sock|fcgi://localhost" .inc .php .phtml .php56
</If>
</FilesMatch>
</Directory>
</VirtualHost>

Related

How to register Options Indexes FollowSymLinks AllowOverride All for directory rule in nginx?

the config file in the Apache site has these lines:
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/www/html/public/
<Directory /var/www/html/public>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_dir.c>
DirectoryIndex index.php index.pl index.cgi index.html index.xhtml index.htm
</IfModule>
now I want to add this rule to the Nginx server. I have a shortener URL website that allows customers to use their own custom domain. How do I allow this in the Nginx config file?
Main Domain: www.example.com
If users want to use their own domain they can add unlimited domains that's what I'm trying to achieve with this code. But basically, it's only for the apache and I have installed the script on Nginx server.

VPS Nginx/ Apache | multi website doesn't work

I've moved 2 domains on the VPS and they work fine, just one at a time.
If I disable one, then the other one works - not both.
dom1.com , dom2.com
have the same DNS records, except the A records with their domain-name pointing to the same IP on the VPS, their DNS records are both on CloudFlare, and they're both configured the same way on the VPS (with aaPanel).
The only difference is their site directory.
Do you know what could trigger this issue?
CentOS 8
aaPanel 6.8.21
Apache 2.4 (same issue on Nginx 1.19)
DNS manager: CloudFlare
Many Thanks
dom1.com | config
DocumentRoot "/www/wwwroot/dom1.com"
ServerName 745e5c8e.dom1.com
ServerAlias dom1.com mail.dom1.com
#errorDocument 404 /404.html
ErrorLog "/www/wwwlogs/dom1.com-error_log"
CustomLog "/www/wwwlogs/dom1.com-access_log" combined
#HTTP_TO_HTTPS_START
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule (.*) https://%{SERVER_NAME}$1 [L,R=301]
</IfModule>
#HTTP_TO_HTTPS_END
#referenced redirect rule, if commented, the configured redirect rule will be invalid
IncludeOptional /www/server/panel/vhost/apache/redirect/dom1.com/*.conf
#DENY FILES
<Files ~ (\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)$>
Order allow,deny
Deny from all
</Files>
#PHP
<FilesMatch \.php$>
SetHandler "proxy:unix:/tmp/php-cgi-73.sock|fcgi://localhost"
</FilesMatch>
#PATH
<Directory "/www/wwwroot/dom1.com">
SetOutputFilter DEFLATE
Options FollowSymLinks
AllowOverride All
Require all granted
DirectoryIndex index.php index.html index.htm default.php default.html default.htm
</Directory>
</VirtualHost>
<VirtualHost *:443>
ServerAdmin webmaster#example.com
DocumentRoot "/www/wwwroot/dom1.com/"
ServerName SSL.dom1.com
ServerAlias dom1.com mail.dom1.com
#errorDocument 404 /404.html
ErrorLog "/www/wwwlogs/dom1.com-error_log"
CustomLog "/www/wwwlogs/dom1.com-access_log" combined
#SSL
SSLEngine On
SSLCertificateFile /www/server/panel/vhost/cert/dom1.com/fullchain.pem
SSLCertificateKeyFile /www/server/panel/vhost/cert/dom1.com/privkey.pem
SSLCipherSuite EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5
SSLProtocol All -SSLv2 -SSLv3 -TLSv1
SSLHonorCipherOrder On
#PHP
<FilesMatch \.php$>
SetHandler "proxy:unix:/tmp/php-cgi-73.sock|fcgi://localhost"
</FilesMatch>
#DENY FILES
<Files ~ (\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)$>
Order allow,deny
Deny from all
</Files>
#PATH
<Directory "/www/wwwroot/dom1.com/">
SetOutputFilter DEFLATE
Options FollowSymLinks
AllowOverride All
Require all granted
DirectoryIndex index.php index.html index.htm default.php default.html default.htm
</Directory>
</VirtualHost>
dom2.com | config
ServerAdmin webmaster#example.com
DocumentRoot "/www/wwwroot/dom2.com"
ServerName 218ac146.dom2.com
ServerAlias dom2.com mail.dom2.com
#errorDocument 404 /404.html
ErrorLog "/www/wwwlogs/dom2.com-error_log"
CustomLog "/www/wwwlogs/dom2.com-access_log" combined
#DENY FILES
<Files ~ (\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)$>
Order allow,deny
Deny from all
</Files>
#PHP
<FilesMatch \.php$>
SetHandler "proxy:unix:/tmp/php-cgi-73.sock|fcgi://localhost"
</FilesMatch>
#PATH
<Directory "/www/wwwroot/dom2.com">
SetOutputFilter DEFLATE
Options FollowSymLinks
AllowOverride All
Require all granted
DirectoryIndex index.php index.html index.htm default.php default.html default.htm
</Directory>
</VirtualHost>
I found the problem.
aaPanel added a wrong sub-domain in their config file.
So fixing that resolved the issue.

How can i fix the root directory of Froxlor?

Migrating Froxlor from a Debian 7 to Debian 8 System.
I have now the problem, that the auto-generated vhost file of Froxlor, has vhost's in it which reference to the wrong directory. Is it possible to change them to the correct destination?
They referencing to /var/www/admin but now i only want them to reference to /var/www. I could not find it in the Database of Froxlor nor in the config Files nor in the Webinterface Settings of Froxlor itself.
The reason to change it is that I have a froxlor installation listening on www.example.com/froxlor and phpMyAdmin on www.example.com/phpmyadmin. Now I want my Overview-Page running on www.example.com.
This is the file which is not correct generated. (I replace the IP's and ServerName's)
# vhosts.conf
# Created 25.09.2016 15:31
# Do NOT manually edit this file, all changes will be deleted after the next domain change at the panel.
Listen 192.168.0.1:443
<VirtualHost 192.168.0.1:443>
DocumentRoot "/var/www/admin/"
ServerName **
FastCgiExternalServer /var/www/php-fpm/froxlor.panel/**/3384.ssl-fpm.external -socket /var/lib/apache2/fastcgi/froxlor.panel-**-php-fpm.socket -idle-timeout 1000
<Directory "/var/www/admin/">
<FilesMatch "\.(php)$">
AddHandler php5-fastcgi .php
Action php5-fastcgi /fastcgiphp
Options +ExecCGI
</FilesMatch>
Require all granted
AllowOverride All
</Directory>
Alias /fastcgiphp /var/www/php-fpm/froxlor.panel/**/3384.ssl-fpm.external
SSLEngine On
SSLProtocol ALL -SSLv2 -SSLv3
SSLHonorCipherOrder On
SSLCipherSuite ECDHE-RSA-AES128-SHA256:AES128-GCM-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH
SSLVerifyDepth 10
SSLCertificateFile /root/froxlor-ssl/cert.pem
SSLCertificateKeyFile /root/froxlor-ssl/key.pem
SSLCACertificateFile /root/froxlor-ssl/root_trust_chain.pem
SSLCertificateChainFile /root/froxlor-ssl/root_trust_chain.pem
</VirtualHost>
Listen 192.168.0.1:80
<VirtualHost 192.168.0.1:80>
DocumentRoot "/var/www/admin/"
ServerName **
FastCgiExternalServer /var/www/php-fpm/froxlor.panel/**/34d3.fpm.external -socket /var/lib/apache2/fastcgi/froxlor.panel-**-php-fpm.socket -idle-timeout 1000
<Directory "/var/www/admin/">
<FilesMatch "\.(php)$">
AddHandler php5-fastcgi .php
Action php5-fastcgi /fastcgiphp
Options +ExecCGI
</FilesMatch>
Require all granted
AllowOverride All
</Directory>
Alias /fastcgiphp /var/www/php-fpm/froxlor.panel/**/34d3.fpm.external
</VirtualHost>
Listen [::1]:443
<VirtualHost [::1]:443>
DocumentRoot "/var/www/admin/"
ServerName **
FastCgiExternalServer /var/www/php-fpm/froxlor.panel/**/e36f.ssl-fpm.external -socket /var/lib/apache2/fastcgi/froxlor.panel-**-php-fpm.socket -idle-timeout 1000
<Directory "/var/www/admin/">
<FilesMatch "\.(php)$">
AddHandler php5-fastcgi .php
Action php5-fastcgi /fastcgiphp
Options +ExecCGI
</FilesMatch>
Require all granted
AllowOverride All
</Directory>
Alias /fastcgiphp /var/www/php-fpm/froxlor.panel/**/e36f.ssl-fpm.external
SSLEngine On
SSLProtocol ALL -SSLv2 -SSLv3
SSLHonorCipherOrder On
SSLCipherSuite ECDHE-RSA-AES128-SHA256:AES128-GCM-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH
SSLVerifyDepth 10
SSLCertificateFile /root/froxlor-ssl/cert.pem
SSLCertificateKeyFile /root/froxlor-ssl/key.pem
SSLCACertificateFile /root/froxlor-ssl/root_trust_chain.pem
SSLCertificateChainFile /root/froxlor-ssl/root_trust_chain.pem
</VirtualHost>
Listen [::1]:80
<VirtualHost [::1]:80>
DocumentRoot "/var/www/admin/"
ServerName **
FastCgiExternalServer /var/www/php-fpm/froxlor.panel/**/fae9.fpm.external -socket /var/lib/apache2/fastcgi/froxlor.panel-**-php-fpm.socket -idle-timeout 1000
<Directory "/var/www/admin/">
<FilesMatch "\.(php)$">
AddHandler php5-fastcgi .php
Action php5-fastcgi /fastcgiphp
Options +ExecCGI
</FilesMatch>
Require all granted
AllowOverride All
</Directory>
Alias /fastcgiphp /var/www/php-fpm/froxlor.panel/**/fae9.fpm.external
</VirtualHost>
Is it possible to disable the root directory auto creation of froxlor? And use this solution. http to https
<VirtualHost *:80>
ServerName **
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_php5.c>
php_admin_flag display_errors off
php_admin_flag display_startup_errors off
</IfModule>
RewriteEngine on
RewriteCond %{SERVER_NAME} =**
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</VirtualHost>
<VirtualHost *:443>
ServerName **
DocumentRoot /var/www/website/silex/web/
<Directory /var/www/website/silex/web/>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
DirectoryIndex /index.php
FallbackResource /index.php
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
<IfModule mod_php5.c>
php_admin_flag display_errors on
php_admin_flag display_startup_errors on
</IfModule>
SSLEngine On
SSLHonorCipherOrder On
SSLCipherSuite ECDHE-RSA-AES128-SHA256:AES128-GCM-SHA256:RC4:HIGH:!MD5:!aNULL:!EDH
SSLVerifyDepth 10
SSLCertificateFile /root/ssl/cert.pem
SSLCertificateKeyFile /root/ssl/key.pem
</VirtualHost>
The Alias Config Files:
# froxlor default Apache configuration
Alias /froxlor /var/www/froxlor/
<Directory /var/www/froxlor/>
Options FollowSymLinks
DirectoryIndex index.php
Require all granted
</Directory>
I found the solution.
You can set it up in the Webinterface under ips and ports. And edit the Ip Adresses their.
Ressourcen/IPs and Ports/Optionen | Edit
Their is the userdefined document root for the Website.
It was not under System Settings.

wildcard subdomain with mod_wsgi + apache + pyramid

I've created a wildcard subdomain using cpanel and attempting to point all sub domains to a particular .wsgi file.
<VirtualHost my.server_ip.address:9999>
ServerName _wildcard_.domain.tld
ServerAlias *.domain.tld
# DocumentRoot /home/my_acct/public_html
ServerAdmin webmaster#domain.tld
UseCanonicalName Off
CustomLog /usr/local/apache/domlogs/_wildcard_.domain.tld combined
CustomLog /usr/local/apache/domlogs/_wildcard_.domain.tld-bytes_log "%{%s}t %I .\n%{%s}t %O ."
## User my_acct # Needed for Cpanel::ApacheConf
UserDir enabled my_acct
<IfModule mod_suphp.c>
suPHP_UserGroup my_acct my_acct
</IfModule>
<IfModule !mod_disable_suexec.c>
<IfModule !mod_ruid2.c>
SuexecUserGroup my_acct my_acct
</IfModule>
</IfModule>
<IfModule mod_ruid2.c>
RMode config
RUidGid my_acct my_acct
</IfModule>
<IfModule itk.c>
# For more information on MPM ITK, please read:
# http://mpm-itk.sesse.net/
AssignUserID my_acct my_acct
</IfModule>
ScriptAlias /cgi-bin/ /home/my_acct/public_html/cgi-bin/
# To customize this VirtualHost use an include file at the following location
Include "/usr/local/apache/conf/userdata/std/2_2/my_acct/wildcard_safe.domain.tld/*.conf"
</VirtualHost>
The following code is what is in wildcard_safe.domain.tld/*.conf and there is only 1 .conf which I name it as subdomain.conf
SetEnvIf Host "^(\w+).domain.tld" subdomain=$1
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
WSGIDaemonProcess pyramid_subdomain user=my_acct group=my_acct threads=4 \
python-path=/home/my_acct/modwsgi/env/lib/python2.6/site-packages
WSGIScriptAlias / /home/my_acct/modwsgi/env/pyramidsub_%{ENV:subdomain}.wsgi
WSGIScriptAlias /admin /home/my_acct/modwsgi/env/pyramidsub_%{ENV:subdomain}.wsgi
<Directory /home/my_acct/modwsgi/env>
WSGIProcessGroup pyramid_subdomain
Order allow,deny
Allow from all
</Directory>
The following is the pyramidsub_test.wsgi file
from pyramid.paster import get_app, setup_logging
ini_path = '/home/my_acct/modwsgi/env/MyFirstApp/production_subtest.ini'
setup_logging(ini_path)
application = get_app(ini_path, 'main')
I've also ensured that there's a pyramidsub_test.wsgi in /home/my_acct/modwsgi/env/.
After setting all this up, I did a apache restart, and go to test.mydomain.com.
However it is showing a website not found, I've checked on apache error_log, but I can't
find any errors being logged. However, I have no problem viewing the main
domain ( www.domain.com )
This is my first time doing server setup, etc, coming from a php background.
Any help is much appreciated.

Zpanel output error: This domains disk limit has been exceeded?

Automatically zpanel showing This domains disk limit has been exceeded! for all the websites hosted in VPS with ZPanel
This domains disk limit has been exceeded!
I don't know why this problem occurs but the solutions what I got
Edited /etc/zpanel/configs/apache/httpd-vhosts.conf
Problem Caused Virtual Host Code
# DOMAIN: domain.in
# THIS DOMAIN HAS BEEN DISABLED FOR QUOTA OVERAGE
<virtualhost *:80>
ServerName domain.in
ServerAlias domain.in www.domain.in
ServerAdmin admin#domain.in
DocumentRoot "/etc/zpanel/panel/etc/static/diskexceeded"
<Directory />
Options FollowSymLinks Indexes
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
AddType application/x-httpd-php .php3 .php
DirectoryIndex index.html index.htm index.php index.asp index.aspx index.jsp index.jspa index.shtml index.shtm
</virtualhost>
# END DOMAIN: domain.in
################################################################
Replaced with
################################################################
# DOMAIN: domain.in
<virtualhost *:80>
ServerName domain.in
ServerAlias domain.in www.domain.in
ServerAdmin zadmin#localhost
DocumentRoot "/var/zpanel/hostdata/zadmin/public_html/domain_in"
php_admin_value open_basedir "/var/zpanel/hostdata/zadmin/public_html/domain_in:/var/zpanel/temp/"
php_admin_value suhosin.executor.func.blacklist "passthru, show_source, shell_exec, system, pcntl_exec, popen, pclose, proc_open, proc_nice, proc_terminate, proc_get_status, proc_close, leak, apache_child_terminate, posix_kill, posix_mkfifo, posix_setpgid, posix_setsid, posix_setuid, escapeshellcmd, escapeshellarg, exec"
ErrorLog "/var/zpanel/logs/domains/zadmin/cessindia.in-error.log"
CustomLog "/var/zpanel/logs/domains/zadmin/cessindia.in-access.log" combined
CustomLog "/var/zpanel/logs/domains/zadmin/cessindia.in-bandwidth.log" common
<Directory />
Options FollowSymLinks Indexes
Require all granted
AllowOverride All
Order Allow,Deny
Allow from all
</Directory>
AddType application/x-httpd-php .php3 .php
ScriptAlias /cgi-bin/ "/_cgi-bin/"
<location /cgi-bin>
AddHandler cgi-script .cgi .pl
Options ExecCGI
</location>
ErrorDocument 500 /_errorpages/500.html
ErrorDocument 403 /_errorpages/403.html
ErrorDocument 404 /_errorpages/404.html
ErrorDocument 510 /_errorpages/510.html
DirectoryIndex index.html index.htm index.php index.asp index.aspx index.jsp index.jspa index.shtml index.shtml
</virtualhost>
# END DOMAIN: domain.in
Better Option:
SSH to the server,
type service httpd restart
That's it and problem solved!
Such kind of Problem is happened under the zpanel control panel
first you have to change value of disk quota under the package manager "i.e 0 for unlimited" save it and then reload your apache, see the result