LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   External IP for Virtual Server (https://www.linuxquestions.org/questions/linux-networking-3/external-ip-for-virtual-server-262705/)

Terra Niux 12-04-2004 10:18 PM

External IP for Virtual Server
 
Hello i'm using Virtualmin to create virtual servers however im still quite new to the idea of using these virtual servers, I understand that I can modify the default apache server then people can access this default server via the external IP say http://60.240.96.175:80 and I can access via the internal IP http://10.0.0.10 or localhost my question is that if I create a virtual server how can I access it externally over the internet without getting the default website to appear but the virtual server instead?

I hope I am being clear enough, thanks for your help.

linux_terror 12-04-2004 10:38 PM

at the bottom of your http.conf you sould see a section called VirtualHosts, this is where you will add the virtual hosts, there are many different techniques for this, assuming that you will be using name based virtual hosting as opposed to ip based virtual hosting tou will also want to uncomment the line that says NameVirtualHost 192.168.0.4:80 substituting the address for your NIC's local address.

here's an example of a virtualhost entry

<VirtualHost 192.168.0.4:80>
ServerAdmin webmaster@example.com
DocumentRoot /var/www/html
ServerName example.com
ErrorLog logs/example.com-error_log
TransferLog logs/example.com-access_log
</VirtualHost>

These entries can get very complex depending on what you want to do, I'd suggest starting out simple.

Hope this helps,
linux_terror

Terra Niux 12-04-2004 10:43 PM

Okay let's say that I am not using any names at the moment just IP addresses, a person accessing the virtual server from the internet cant access the virtual interface IP tho can they? I want people from the internet to be able to view the virtual servers aswell say like a web host how they have many different users.. i'm quite confused. The default server uses 10.0.0.10 this can be accessed by my internet IP but the virtual server uses 10.0.0.11 what IP can I give people to access this? I am not using DNS or names atm tho.

Terra Niux 12-04-2004 10:45 PM

Can virtual servers only be accessed by the internal network?

linux_terror 12-04-2004 11:25 PM

The only way I can think of to do what you are asking is a workaround, and that would be to set up permanent redirects for subdirectories of the main site to non-standard ports that are forwarded to the other local ip's by your router.
Its not the "right" way to go about it. If I were you I'd invest 6 dollars in a domain name and learn a bit about hosting your own dns. You could then at least set up subdomains to point to other websites. If you had multiple external(WAN) ip addresses to work with it would be possible but that would cost more than just getting a domain name anyway.

linux_terror

Demonbane 12-05-2004 12:18 AM

Put it this way, basically there's 2 types of virtualhosts in Apache, ip-based and name-based.

With ip-based Apache serves content based on which ip address the client connects to(ie you have more than one public ip addresses, and you setup vhosts on each of them)

With name-based Apache checks the domain name which the client used to connect, and serves content based on that. If you configured name-based vhosts and client uses the ip address to connect , the default vhost will be used(usually the first one defined in the configuration file)

Therefore, for your situation if you have an ip-based configuration, why not just put the website you want external clients to see on the external IP, since they will only be able to access your public IP address anyway. If you're behind a router simply forward port 80 to whichever LAN ip the virtualhost is using on the server.
Also if you want to use name-based virtualhosts without purchasing a domain name there's plenty of free DNS services around, here's one I personally use:
http://www.afraid.org

For anything more complex you need to learn how to use mod_rewrite.

Terra Niux 12-05-2004 12:24 AM

Basically what I want to do is to have at least 5 websites hosted for people, I want them to be able to log in via FTP into a folder which contains their websites and where they can update their websites, I then want apache to look into these directories. Are there any good tutorials on this sort of work? any examples? I am still confused on configuring domain names.

Demonbane 12-05-2004 12:47 AM

The simplest way would be using mod_userdir
You put this in your Apache config file(might even be enabled already depending on your distro):
Code:

<IfModule mod_userdir.c>
  UserDir public_html
</IfModule>

Then create local user accounts for each user, their root web directory will be in ~/public_html. So for user "john", he has to upload his stuff to /home/john/public_html, and it can be accessed via http://yourserver/~john/

Using DNS for name-based virtualhost, eg john can access his website using http://john.yourdomain.com, is a little more complex. If mod_userdir does not achieve what you want let me know, I can give you another short tutorial.

linux_terror 12-05-2004 01:24 AM

BEWARE: If you add hosts using mod_userdir and have ssh/sftp access open to the outside these clients will be able to browse above their home directories.

It sounds like what you want to do is build a LAMP style mass hosting environment. There are many tutorials on this and it is quite an endeavor. If you need help just keep posting, I have set up quite a few of them. Demonbane is right, for your purposes now mod_userdir is probably the best way to go.

linux_terror

Terra Niux 12-05-2004 01:31 AM

Okay I tried modifying the Apache config, however I cannot seem to access my server from my Windows XP machine, the IP is http://10.0.0.10 but I cannot load http://10.0.0.10/~lindsay, can you tell me why? Although when I use Lynx and goto http://10.0.0.10/~lindsay I get the following error


Forbidden

You don't have permission to access /~lindsay/ on this server.
_________________________________________________________________


Apache/1.3.31 Server at server.lan Port 80


Do I have to chmod the directory or something?

Thanks

linux_terror 12-05-2004 01:34 AM

chmod 755 /home/lindsay /home/lindsay/public_html

Terra Niux 12-05-2004 01:38 AM

Unfortunately I still get the error after I did chmod 755 /home/lindsay,

Here is some information

root@server:/home# ls -l
drwxr-xr-x 4 lindsay users 4096 2004-12-04 04:43 lindsay/

root@server:/home# cd ~lindsay
root@server:/home/lindsay# ls -l
drwxr-xr-x 2 root root 4096 2004-12-04 04:43 public_html/

linux_terror 12-05-2004 01:42 AM

did u restart the webserver?

you'll also want to
Code:

chown lindsay:lindsaysgroup public_html
so that lindsay can write to it

Demonbane 12-05-2004 01:53 AM

Did you put any index files(index.htm etc) in public_html? I think the default Apache installation in most distro disallows directory browsing unless you specify otherwise.

Terra Niux 12-05-2004 01:59 AM

I just rebooted the box, now i've got another problem *sigh*

Failed to start apache : Apache does not appear to be running :
[Sat Dec 4 05:15:26 2004] [warn] NameVirtualHost 10.0.0.10:80 has no VirtualHosts
/usr/sbin/apachectl start: httpd started

:confused:

Help me please :Pengy:


All times are GMT -5. The time now is 03:45 PM.