Can linux host mutiple websites with one domain's different third domains? - dns

I recently made some projects on raspberry pi with linux Debian Jessie, and I am interested in porting forward websites hosted on raspberry pi to a domain I owned.
From what I learned, it is possible to make each individual website on raspberry link with configured port according to apache , for example /home/pi/html/website01 -> port 11235 website02 -> 11236 so that I can browse the websites in private network. However, the domain I have is managed by godaddy, they provide the Chain without port, so that I can't redirect one of my third level domain(ex dashboard.domain.com to my dynamic dns hostname xx.dtdns.net with the port.
Is there any possible way or idea to get it work? I am lack of knowledge of nameserver, but I have an idea that using vpn or vps to map users to my private network instead of godaddy domain manager. I have alreay built the openvpn with cert and pptp vpn on my raspberrypi. Is it possible or what's next step?
Thanks, please give me some idea.

One solution would be to use Virtual Hosting in Apache on your Raspberry. Install Apache2 on PI with:
apt-get install apache2
Create a new conf file in /etc/apache2/sites-available or use an existing one. Add the ports for different site directories:
<VirtualHost *:11235>
DocumentRoot /var/www/w1
<Directory /var/www/w1>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:11236>
DocumentRoot /var/www/w2
<Directory /var/www/w2>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
</VirtualHost>
and then set Apache tolisten on the ports in the /etc/apache2/ports.conf file:
Listen 11235
Listen 11236
Restart the Apache service. You should now be able to browse both ports using the same ip address. If your ip was 111.111.111.111 then w1 directory on 111.111.111.111:11235 and 111.111.111.111:11236.
If your domain is pointing to a IP, you can use different hostnames without making change to DNS. If you domain was mydomain.com, you could instead add new virtual host names with:
<VirtualHost *:80>
ServerName w1.mydomain.com
DocumentRoot /var/www/w1
<Directory /var/www/w1>
Options +Includes -Indexes +FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName w2.mydomain.com
DocumentRoot /var/www/w2
<Directory /var/www/w2>
Options +Includes -Indexes +FollowSymLinks
AllowOverride All
Order allow,deny
allow from all
</Directory>
</VirtualHost>

Related

Apache VirtualHost Setup on QNAP for Sub Sirectories

I am trying to setup vHost on my QNAP web server (Running Apache). I seem to be stuck at the point where I can't load the subdomains. I have included a custom conf file in the apache.conf file like so:
include /share/Web/customapache.conf
In the customapache file, I have the following:
NameVirtualHost *:80
ServerName 127.0.0.1
DocumentRoot "/share/Web/site1-home"
<Directory />
Order deny,allow
Deny from all
</Directory>
ServerSignature Off
ServerTokens Prod
NameVirtualHost *:80
<VirtualHost *:80>
ServerName localhost
# ServerAlias www.localhost
DocumentRoot "/share/Web/site1-home"
<Directory "/share/Web/site1-home">
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerName pods.localhost
# ServerAlias www.pods.localhost
DocumentRoot "/share/Web/site2-pods"
<Directory "/share/Web/site2-pods">
Options FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
It's probably a bit of a mess as I have been trying multiple different examples trying to fix whatever issues I have. I am fairly new to linux, and apache to be honest. I was able to get it all working fine in NGINX, however I ran into some compatability issues with QNAP.
Essentially, the main redirect is working, so that the base directory is now /share/Web/site1-home, but the subdomain is not working (pods.localhost). I am sure its something simple I am missing, or even something I have added that I do not need. But any assistance, or even a point in the right direction would be much appreciated.
Regards
Kirt

Apache VirtualHost from user directory on Amazon EC 2

I'm coming from a non-cloud hosting background on Red Hat Enterprise Linux and/or CentOS and trying to set up an apache (2.2) server with Amazon EC2. I typically host my files from a user's home directory and create a virtualhost like so:
<VirtualHost *:80>
ServerName userdomain.com
DocumentRoot /home/myuser/public_html
<Directory /home/myuser/public_html>
AllowOverride All
<Limit DELETE>
Order Deny,Allow
Deny from All
</Limit>
</Directory>
</VirtualHost>
However on Amazon EC2 that doesn't seem to work at all no matter how I sent the file permissions.
Is this something that just isn't allowed? Do I have to host files from /var/www? What am I missing?
It turns out Linux had SELinux enabled, which I have not encountered before.
The simplest solution was to put it in "permissive" mode as described at
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security-Enhanced_Linux/sect-Security-Enhanced_Linux-Enabling_and_Disabling_SELinux-Disabling_SELinux.html

/etc/hosts configuration not being detected

Am configuring a local linux development environment utilizing apache, i can access the url:
http://localhost:8080
but not the configured virtualhost entries which are also present in the /etc/hosts file e.g if i enter:
http://admin:8080
in my browser redirects me to www.admin.com, which is an external address.
/etc/hosts file has the following entries:
127.0.0.1 localhost admin jobboard
127.0.1.1 rob-VirtualBox
Apache config(virtual hosts reference the above entries admin and jobboard):
Listen 8080
Port 8080
ServerName 127.0.0.1:8080
DocumentRoot "/var/www/html/BigRedSkyASAP/virtualhosts"
<Directory "/var/www/html/BigRedSkyASAP/virtualhosts">
NameVirtualHost *:8080
<VirtualHost 127.0.0.1:8080>
ServerName admin
# set the document root
DocumentRoot "/var/www/html/BigRedSkyASAP/virtualhosts/Client-asap.bigredsky.com"
# set the directory settings
<Directory "/var/www/html/BigRedSkyASAP/virtualhosts/Client-asap.bigredsky.com">
Options All Includes Indexes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
<VirtualHost 127.0.0.1:8080>
ServerName jobboard
# set the document root
DocumentRoot "/var/www/html/BigRedSkyASAP/virtualhosts/JobBoard-asapdev.bigredsky.com"
# set the directory settings
<Directory "/var/www/html/BigRedSkyASAP/virtualhosts/JobBoard-asapdev.bigredsky.com">
Options All Includes Indexes
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
Apache and Computer was restarted after changes to config files were saved.
Is their some other hosts configuration file which needs to be modified? Running linux mint OS.
Thanks in advance.
in the virtual host config try this for admin
ServerAlias admin
that should resolve the admin website to local server
furthermore check whether you are under any proxy...you should turn it off...
create one more vhost entry for admin
<VirtualHost 127.0.0.1:8080>
ServerName admin

Resolving virtual hosts apache 2

I'm trying to setup my apache server to access certain folders when I type addresses like test1.example.com test2.example.com etc.
So far I read and did many things but with no success yet. I'll be very thankful if you can help me.
So to start I'm using ubuntu 12.10 as my desktop and I've set up apache server there. I've added example.com in hosts resolving to 127.0.0.1. So far no problems. I've enable vhost_alias and mod_rewrite in apache and I'm using this for my virtual server
NameVirtualHost *:80
UseCanonicalName Off
<VirtualHost *:80>
ServerName example.com
ServerAlias *.example.com
RewriteEngine On
RewriteCond %{HTTP_HOST} !^(www\.)?([^\.]+).example.com$
RewriteRule ^(.*) $1 [F]
VirtualDocumentRoot /home/example/server/projects/%1/public_html
<Directory />
Options FollowSymLinks
AllowOverride all
</Directory>
<Directory /home/radoslav/server/projects>
Options Indexes FollowSymLinks MultiViews
AllowOverride all
Order allow,deny
allow from all
</Directory>
#log file for this server
CustomLog /var/log/apache2/example.com.log combined
</VirtualHost>
But when I open test.example.com it says that browser can find test.example.com, no matter that I have this directory in the path specified. Just to clear things up apache have permissions to read this directory so it's not this. When I ping example.com from console I get ping but if I ping test.example.com I get error that can not find host. As you can see obviously it's not resolving the adress no matter that I've setup everything correcly.
Any help guys?
You need to add test.example.com and any other hostnames you want to use in the host file. The host file does not supports wildcard.

Creating subdomains in Amazon EC2

How can I create subdomains on Amazon EC2?
Is adding virtual host in httpd.conf is enough.. or any other changes also needs to be done?
Thanks
Depends on your server software. But as you mention httpd.conf, chances are good that you run Apache on a Linux distribution. If that's the case then yes, adding a virtual host is enough. Here is one way of doing it:
Purchase a domain. If you have one, skip this, we'll take example.com for this example.
Find the external IP or DNS for your EC2 instance. You probably want to associate an Elastic IP to your instance, otherwise the IP of your instance will change on reboots.
Create a DNS record for your domain, for instance a CNAME record to point to your Elastic IP/DNS name:
subdomain.example.com => ec2-xx-xxx-xxx-xxx.eu-west-1.compute.amazonaws.com
Make sure your httpd.conf contains a line to allow virtual hosts:
NameVirtualHost *:80
Create a virtual host directive:
httpd.conf:
<VirtualHost *:80>
ServerName subdomain.example.com
ServerAdmin webmaster#subdomain.example.com
DocumentRoot /var/www/example.com/subdomain
<Directory /var/www/example.com/subdomain>
Options Indexes FollowSymLinks MultiViews
AllowOverride All
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/subdomain.example.com.error.log
LogLevel warn
CustomLog /var/log/apache2/subdomain.example.com.access.log combined
</VirtualHost>
6. Restart Apache
/etc/init.d/apache2 restart

Resources