So I have two web sites hosted on the same server and same IP address. Ok no biggie. I setup my httpd.conf file in a way I believe is correct. The first site, cascocc.com works no problem. The second site coloradospringshomebuilders.com is the problem. It redirects to http://coloradospringshomebuilders.com/cgi-sys/defaultwebpage.cgi and the www alias does not work. Below is what I think are the relevant parts for my config file with the rest in a paste bin below. I have also included the .htaccess files below as well too. Any ideas?
I am getting a 403 forbidden error any time i try to access anything in the document root. How do I correct this
http.conf file can be found here
.htaccess file for coloradospringshomebuilders.com
.htaccess file for cascocc.com
<VirtualHost 216.172.182.170:80>
ServerName 216.172.182.170
DocumentRoot /usr/local/apache/htdocs
ServerAdmin root#cas.cascocc.com
<IfModule mod_suphp.c>
suPHP_UserGroup nobody nobody
</IfModule>
</VirtualHost>
# Default vhost for unbound IPs
<VirtualHost *>
ServerName cas.cascocc.com
DocumentRoot /usr/local/apache/htdocs
ServerAdmin root#cas.cascocc.com
<IfModule mod_suphp.c>
suPHP_UserGroup nobody nobody
</IfModule>
</VirtualHost><VirtualHost 216.172.182.170:80>
ServerName cascocc.com
ServerAlias www.cascocc.com
DocumentRoot /home/cascocc/public_html
ServerAdmin xxx#cascocc.com
UseCanonicalName Off
CustomLog /usr/local/apache/domlogs/cascocc.com combined
CustomLog /usr/local/apache/domlogs/cascocc.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
<IfModule itk.c>
# For more information on MPM ITK, please read:
# http://mpm-itk.sesse.net/
AssignUserID cascocc cascocc
</IfModule>
ScriptAlias /cgi-bin/ /home/cascocc/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/cascocc/cascocc.com/*.conf"
</VirtualHost>
# DO NOT EDIT. AUTOMATICALLY GENERATED. IF YOU NEED TO MAKE A CHANGE PLEASE USE THE INCLUDE FILES.
<VirtualHost 216.172.182.170:80>
ServerName coloradospringshomebuilders.com
ServerAlias www.coloradospringshomebuilders.com
DocumentRoot /home/cascohomes/public_html
ServerAdmin xxx#coloradospringshomebuilders.com
UseCanonicalName Off
CustomLog /usr/local/apache/domlogs/coloradospringshomebuilders.com combined
CustomLog /usr/local/apache/domlogs/coloradospringshomebuilders.com-bytes_log "%{%s}t %I .\n%{%s}t %O ."
<IfModule itk.c>
# For more information on MPM ITK, please read:
# http://mpm-itk.sesse.net/
AssignUserID cascohomes cascohomes
</IfModule>
ScriptAlias /cgi-bin/ /home/cascohomes/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/cascohomes/coloradospringshomebuilders.com/*.conf"
</VirtualHost>
Related
My website open properly when I type `www.abc.com` on browser but when I type `abc.com` it opens page of subdomain which I have hosted which is `admin.abc.com`.
But the url still says `abc.com`
Here is my .htaccess code:
<!-- language: lang-bash -->
RewriteEngine on
RewriteBase /
RewriteCond %{HTTP_HOST} !^www\. [NC]
RewriteRule ^(.*)$ http://www.%{HTTP_HOST}/$1 [R=301,L]
I am using Ubuntu 14.04 with Apache and have configured virtual hosts for both domains.
Any guidance will be highly appreciated.
Here is my conf file for abc.com which is uploaded on the server for both domain and sub-domain.
<!-- language: lang-bash -->
# domain: abc.com
# public: /var/www/abc.com/public_html/
<VirtualHost *:443>
SSLEngine On
SSLCertificateFile /etc/ssl/localcerts/c8d39f3574580de6.crt
SSLCertificateKeyFile /etc/ssl/localcerts/abc.key
SSLCertificateChainFile /etc/ssl/localcerts/gd_bundle-g2-g1.crt
<Directory /var/www>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin admin#abc.com
ServerName abc.com
ServerAlias abc.com
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /var/www/abc.com/public_html
# Log file locations
LogLevel warn
ErrorLog /var/www/abc.com/log/error.log
CustomLog /var/www/abc.com/log/access.log Combined
</VirtualHost>
Here is my conf file for admin.abc.com
<!-- language: lang-bash -->
# domain: admin.abc.com
# public: /var/www/admin.abc.com/public_html/
<VirtualHost *:80>
# Admin email, Server Name (domain name), and any aliases
ServerAdmin admin#abc.com
ServerName admin.abc.com
ServerAlias admin.abc.com
# Index file and Document Root (where the public files are located)
DirectoryIndex index.html index.php
DocumentRoot /var/www/admin.abc.com/public_html
# Log file locations
LogLevel warn
ErrorLog /var/www/admin.abc.com/log/error.log
CustomLog /var/www/admin.abc.com/log/access.log combined
</VirtualHost>
do let us know if above conf files where helpful to determine the issue, Looking forward to your response.
Do you have your Virtual Host configuration correctly configured?
I would recommend you using a configuration file instead of .htaccess if you are able to.
(under: /etc/apache2/sites-enabled or sites-available, if it has not been activated yet)
<VirtualHost *:80>
# With this configuration when you try to reach both www.abc.com
# and abc.com it directs you to the same place.
# If you got a subdomain, you should create a separate .conf file
# with the correct configurations as well.
ServerAdmin admins#email.com
ServerName www.abc.com
ServerAlias abc.com
DocumentRoot /var/www/path/to/websites/folder
# Some more comments...
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# More comments...
</VirtualHost>
After editing this, do not forget to restart the Apache server:
sudo service apache2 restart
or
sudo systemctl restart apache2.service
Hope it helps.
I have multiple A record for the same server IP address, I mean:
URL DNS res.
goodurl.com 10.0.0.1
badurl1.com 10.0.0.1
badurl2.com 10.0.0.1
I would like to configure Apache2 so that it works only with URL goodurl.com and not with any other.
I've found the way to give "access denied" on specific URL "badurl1.com" like this :
<VirtualHost *:80>
ServerName badurl1.com
DocumentRoot /var/www
<Directory /var/www/>
AllowOverride None
Order deny,allow
deny from all
</Directory>
</VirtualHost>
Is there a more elegant and efficent way to do the same?
Is there a way to configure Apache to be sure that any other future and undesired new A record, will be rejected by default?
thanks in advance for your help
system SO: Linux 2.6.32-5-amd64 x86_64 GNU/Linux
Server version: Apache/2.2.16 (Debian)
A friend suggested me to add this at the bottom of the config file. It works as I expected.
The trick is to create a (pseudo)random ServerName and to give an "*" as ServerAlias.
This way it matches my correct config for the ServerName and ServerAlias I've configured at the top and fallback on "fail" dir (with no access rights) for all other URLs poiting to my IP.
lupo#pippo:/var/www# mkdir fail
lupo#pippo:/var/www# chmod -R 000 fail
<VirtualHost *:80>
ServerName goodurl.com
ServerAlias www.goodurl.com goodurl
........
........
</VirtualHost>
<VirtualHost *:80>
ServerName lkfjLKJfiu90FJIDSNMFLKSDFMLKSDJNFLKSDFHIDOFH89DFY89NNS
ServerAlias *
DocumentRoot /var/www/fail
<Directory /var/www/fail/>
AllowOverride None
Order deny,allow
deny from all
</Directory>
</VirtualHost>
You should use dynamic virtual host. Essentially the path name will contain the virtual host server name, so that if the path does not exist, the server will return file not found.
<VirtualHost 111.22.33.44>
ServerName customer-1.example.com
DocumentRoot /www/hosts/customer-1.example.com/docs
ScriptAlias /cgi-bin/ /www/hosts/customer-1.example.com/cgi-bin
</VirtualHost>
<VirtualHost 111.22.33.44>
ServerName customer-2.example.com
DocumentRoot /www/hosts/customer-2.example.com/docs
ScriptAlias /cgi-bin/ /www/hosts/customer-2.example.com/cgi-bin
</VirtualHost>
<VirtualHost 111.22.33.44>
ServerName customer-N.example.com
DocumentRoot /www/hosts/customer-N.example.com/docs
ScriptAlias /cgi-bin/ /www/hosts/customer-N.example.com/cgi-bin
</VirtualHost>
becomes
# get the server name from the Host: header
UseCanonicalName Off
# this log format can be split per-virtual-host based on the first field
# using the split-logfile utility.
LogFormat "%V %h %l %u %t \"%r\" %s %b" vcommon
CustomLog logs/access_log vcommon
# include the server name in the filenames used to satisfy requests
VirtualDocumentRoot /www/hosts/%0/docs
VirtualScriptAlias /www/hosts/%0/cgi-bin
http://httpd.apache.org/docs/current/vhosts/mass.html
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.
I have my server side at http://example.co.uk, which is accessible in a web browser (or via a normal http request) to http://example.co.uk. However, for my app to be able to access the server side, I'd like it to be able to access exactly the same content on port 5678. So I tried to program this in virtualHosts in my apache config:
<VirtualHost 184.107.24.1:80>
ServerName example.co.uk
ServerAlias www.example.co.uk
DocumentRoot /home/example/public_html
ServerAdmin webmaster#example.co.uk
UseCanonicalName Off
CustomLog /usr/local/apache/domlogs/example.co.uk combined
CustomLog /usr/local/apache/domlogs/example.co.uk-bytes_log "%{%s}t %I .\n%{%s}t %O ."
## User example # Needed for Cpanel::ApacheConf
UserDir enabled example
<IfModule mod_suphp.c>
suPHP_UserGroup example example
</IfModule>
<IfModule !mod_disable_suexec.c>
<IfModule !mod_ruid2.c>
SuexecUserGroup example example
</IfModule>
</IfModule>
<IfModule mod_ruid2.c>
RUidGid example example
</IfModule>
ScriptAlias /cgi-bin/ /home/example/public_html/cgi-bin/
# To customize this VirtualHost use an include file at the following location
# Include "/usr/local/apache/conf/userdata/std/2/example/example.co.uk/*.conf"
</VirtualHost>
(that is what I had originally). I have tried adding Listen 5678 and adding 3 lines about a proxy request:
ProxyRequest Off
ProxyPass / http://example.co.uk:5678/
ProxyPassReverse / http://example.co.uk:5678/
Edit your ports.conf file as :
NameVirtualHost *:80
Listen 80
NameVirtualHost *:5678
Listen 5678
Change the VirtualHost definition by
<VirtualHost 184.107.24.1:80 184.107.24.1:5678>
I've added VirtualHost
ServerAdmin root#localhost
DocumentRoot /var/www/html/blogovet.ru
ServerName www.blogovet.ru
ServerAlias blogovet.ru
But my script in this domain can see all server files /* not only in his directory /var/www/html/blogovet.ru
How to forbid viewing files except DocumentRoot ?
A script will be able to read all files that the user running the script can read. So you should make sure your web server does not run as root (it needs to be started as root to listen on port 80, but should swich user to e.g. "www" itself), and then make sure that that user can't read any sensible files.
You could also use SElinux for an extra layer of security.
I found this solution for PHP (If disable cgi and ssi, looks good)
<VirtualHost *:80>
ServerAdmin root#localhost
DocumentRoot /var/www/html/site.com
ServerName www.site.com
ServerAlias site.com
ErrorLog /var/www/html/site.com/error-log
# TransferLog /var/www/html/site.com/transfer-log
# CustomLog /var/www/html/site.com/access-log common
<IfModule mod_php5.c>
php_admin_value upload_tmp_dir "/tmp"
php_admin_value include_path ".:/usr/share/pear:/usr/share/php:/var/www/html/site.com"
php_admin_value open_basedir "/var/www/html/site.com"
php_admin_value doc_root "/var/www/html/site.com"
</IfModule>
<Directory "/var/www/html/site.com">
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>