I have a virtual host in ubuntu on apache, this is not my main config, i have another web page as my main, so i wanted to set this one up on the same IP using a virtual host.
urologyexpert.mx is my server name, and this works perfect, but i want to have several aliases to access this page
I put as server alias:
www.urologyexpert.mx (doesn't work)
urologoexpertomonterrey.mx (doesn't work)
www.urologoexpertomonterrey.mx (working)
The one's that does not work gets routed to my default webpage on this IP,
here's my apache config in /etc/apache2/sites-enabled
A records are set up for urologyexpert.mx and urologoexpertomonterrey.mx, both pointing at the same IP, and i have a CNAME for www for urologyexpert.mx
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName urologyexpert.mx
ServerAlias www.urologyexpert.mx, urologoexpertomonterrey.mx, www.urologoexpertomonterrey.mx
DocumentRoot /var/www/urologyexpert.mx
<Directory />
Options FollowSymLinks
AllowOverride All
</Directory>
<Directory /var/www/urologyexpert.mx>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
Can someone help me with this? i just can't figure out why one alias is working and two aren't
Ok, I actually know now what was the problem,
The multiple ServerAlias have to be separated by a space, and not a comma, thats why only the ServerName and the last Alias was working
ServerAlias www.urologyexpert.mx urologoexpertomonterrey.mx www.urologoexpertomonterrey.mx
I hope this helps someone
Related
We have a VUE front end that is within the dist (var/www/dev/dist) folder. We successfully set up when users visit dev.domain.com that it hits the dist folder. The problem we are having is with our api, which is in an api subfolder (var/www/dev/api/public). What we are trying to accomplish is when the URL dev.domain.com/api is called it points to /var/www/dev/api/public and will also handle all requests appended to api (dev.domain.com/api/*).
<VirtualHost *:80>
ServerAdmin webmaster#localhost
Servername dev.domain.com
ServerAlias dev.domain.com
Alias /api /var/www/dev/api/public
<Directory /var/www/dev/api>
Options All
AllowOverride All
order allow,deny
allow from all
</Directory>
DocumentRoot /var/www/dev/dist
<Directory "/var/www/dev">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/dev-domain.log
# Possible values include: debug, info, notice, warn, errot, crit
# alert, emerg.
LogLevel warn
Customlog ${APACHE_LOG_DIR}/dev-domain-access.log combined
</Virtualhost>
After some more researching and help from the above comment I ended up getting it to work with the following Virtual Hosts config.
<VirtualHost *:80>
ServerAdmin webmaster#localhost
Servername dev.domain.com
DocumentRoot /var/www/dev/dist/
<Directory "/var/www/dev/">
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
Alias /api/ "/var/www/dev/api/public/"
<Directory "/var/www/dev/api/public/">
Options Indexes FollowSymLinks
</Directory>
ErrorLog ${APACHE_LOG_DIR}/dev-domain.log
# Possible values include: debug, info, notice, warn, errot, crit
# alert, emerg.
LogLevel warn
Customlog ${APACHE_LOG_DIR}/dev-domain-access.log combined
</Virtualhost>
So i cannot get my web server with SSL to work properly. I've googled for 4 hours now trying to get it to work, but i've had no luck.
Let's say my domain name is example.com.
I have a main site at https://example.com and then i have 4 subdomains 1.example, 2.example,3.example and 4.example.
Now the thing is, i can access all subdomains just fine, but when i try to access the main domain it says it cannot connect to the site. What am i doing wrong ??.
Using apache 2.4.20 Stable on Ubuntu 16.04.
Here is the configuration im using for the virtualhosts:
<VirtualHost *:443>
ServerAdmin webmaster#localhost
LoadModule headers_module modules/mod_headers.so
DocumentRoot /var/www/example.com
<Directory /var/www/example.com>
Options FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
RedirectMatch 404 \.token$
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/certs/cert
SSLCertificateKeyFile /etc/apache2/certs/key
ServerName www.example.com
ServerAdmin webmaster#localhost
LoadModule headers_module modules/mod_headers.so
DocumentRoot /var/www/1.example.com
<Directory /var/www/1.example.com>
Options FollowSymLinks Includes ExecCGI
AllowOverride All
Require all granted
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
RedirectMatch 404 \.token$
CustomLog ${APACHE_LOG_DIR}/access.log combined
SSLEngine on
SSLCertificateFile /etc/apache2/certs/cert
SSLCertificateKeyFile /etc/apache2/certs/key
ServerName www.1.example.com
... but when i try to access the main domain it says it cannot connect to the site.
Since there is a web server running on the subdomains but it says that it cannot connect to the main site my guess is that your main site has a different IP address than your subdomains. In this case it does not matter how the config of the web server looks like because it will look for the web server at a different IP address and not find one.
To check the IP address for a host from your client (and only this matters) you can use tools like dig or nslookup on UNIX and Mac or or nslookup on Windows. If you see that your subdomain resolve to a different IP address than your main domain you have found the cause of your problem.
I have the following as my default virtual host in /etc/apache2/sites-available/default
<VirtualHost *:80>
ServerAdmin webmaster#localhost
DocumentRoot /var/customers/webs/speed
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/customers/webs/speed>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
The idea is that it would read the index.html from /var/customers/webs/speed, however, it's still reading the default index.html in /var/www
I have restarted apache and even the server itself, but it just don't seem to want to update.
You must edit /etc/apache2/sites-enabled/default to change default page
If you access http://localhost Apache will load the index.html from Document Root defined in httpd.conf.
If you would like to load Document Root of Virtual Host, try below -
<VirtualHost *:80>
ServerName virtualhost.com
ServerAdmin webmaster#localhost
DocumentRoot /var/customers/webs/speed
<Directory /var/customers/webs/speed>
Options Indexes FollowSymLinks
AllowOverride None
Require all granted
</Directory>
</VirtualHost>
Go to your Host file and add a new entry 127.0.0.1 virtualhost.com
Apache should now understand which document root to load when you access http://localhost and http://virtualhost.com.
The above code would get you started and then you can add your customization accordingly .
Hope that help!
I'm having troubles setting up a moodle instance behind an apache proxy.
Here's my apache front-end that proxies to the running server.
NameVirtualHost www.example.com:443
<VirtualHost www.example.com:443>
ProxyPreserveHost On
ProxyRequests Off
ServerName www.example.com
ServerAlias www.example.com
ProxyPass / http://192.168.1.101/
ProxyPassReverse / http://192.168.1.101/
SSLEngine on
SSLCertificateFile /etc/ssl/crt/example.com.crt
SSLCertificateKeyFile /etc/ssl/crt/example.com.key
SSLCACertificatePath /etc/ssl/crt
SSLCertificateChainFile /etc/ssl/crt/example.com.bundle.crt
</VirtualHost>
On the concrete server I've got.
$CFG->wwwroot = 'http://192.168.1.101/classes';
And
<VirtualHost 192.168.1.101:80>
ServerAlias 192.168.1.101
ServerAdmin webmaster#localhost
ServerName 192.168.1.101
DocumentRoot /var/www/
<Directory />
Options FollowSymLinks
AllowOverride None
</Directory>
<Directory /var/www/>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
Alias /doc/ "/usr/share/doc/"
<Directory "/usr/share/doc/">
Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128
</Directory>
</VirtualHost>
The thing is that I keep getting that moodle is only accessible from 182.168.1.101 something is not quite matching the expected. I've been able to configure confluence and other platforms but moodle doesn't work.
The concrete error is as follows.
Incorrect access detected, this server may be accessed only through "http://192.168.1.101/classes" address, sorry. Please notify server administrator.
Does anyone know what might be happening?
Its a Moodle error message, the wwwroot in config.php has to match.
You could try
$CFG->wwwroot = 'http://' . $_SERVER['HTTP_HOST'];
Although this might not allow some command line updates in Moodle.
On the proxy server, modify the VirtualHost entry as follows:
ProxyPass / http://192.168.1.101/classes
ProxyPassReverse / http://192.168.1.101/classes
For Moodle, what you set in Moodle's config.php for
$CFG->wwwroot
...has to match your ProxyPass and ProxyPassReverse values in the VirtualHost definition on the Proxy server.
So, what's the URL that points to your front end?
That's what you need to set $CFG->wwwroot to.
i have some troubles to install local website for development.
I have an "client denied by server configuration"' error for some local ressources like .png or .js
My website have following treepath :
website/files
website/app/local
website/app/share
My mainpage is in app/local and can access to files /files but i have 403 error for files in app/share.
I put "chmod -R 777 www-data" on full website directory so what's wrong ?
[SOLVING]I have another little problem : i can't access to my website with localhost/website but only with localhost/
I have reading some tutos and think my following configuration is right (my apache is 2.2) :
<VirtualHost *:80>
ServerName julien.quai13.com
DocumentRoot /home/julien-quai13/www
<Directory />
Options FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin julien#andcotransport.com
ServerName julien.quai13.com/andcotransport
DocumentRoot /home/julien-quai13/www/andcotransport
#<Directory />
# Options FollowSymLinks
# AllowOverride All
#</Directory>
<Directory /home/julien-quai13/www/andcotransport>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
And this my /etc/hosts :
127.0.0.1 localhost
127.0.0.1 julien.quai13.com
127.0.1.1 julien-quai13
192.126.0.34 julien.quai13.com
Not very important but annoying, i always have problems when i switch of Wamp to Linux.
Thanks for helping (promise i stay on Linux this time ;)
Well, when using vhosts, if apache doesn't match the URL with any server name, it will serve the first one it comes to, if this is the first one, then localhost will map straight to /home/julien-quai13/www/andcotransport
You should set up a virtualhost for default with DocumentRoot /home/julien-quai13/www and add a Directory directive for this directory, then localhost/andcotransport will work.
Not sure if this is what you meant to write: chmod -R 777 www-data but this is wrong, commands should be chmod -R 755 /home/julien-quai13/www/andcotransport and chown -R julien-quai13:www-data /home/julien-quai13/www/andcotransport
But permissions wouldn't give you a client denied by server configuration error, this is down to allow being set incorrectly.
Also you have defined julien.quai13.com twice in your hosts file.. one points to 127.0.0.1 and another points to 192.126.0.34.. this may be another problem..
Otherwise i'd consider restructuring your vhosts.
Judging by your vhost:
<VirtualHost *:80>
ServerName julien.quai13.com
DocumentRoot /home/julien-quai13/www
<Directory /home/julien-quai13/www>
Options Indexes FollowSymLinks
AllowOverride All
Order allow,deny
Allow from all
</Directory>
ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
<Directory "/usr/lib/cgi-bin">
AllowOverride All
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all
</Directory>
ErrorLog ${APACHE_LOG_DIR}/error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
You don't actually need the second vhost unless its under a different domaing, like andcotransport.julien.quai13.com so, just use the default domain and pass everything to /andcotransport, if thats how you want to do it...
but make sure all your resources are going to /andcotransport/files and /andcotransport/app/share then this should work, unless you have an overriding ACL somewhere which is blocking directories.