<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.openvz.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Hvdkamer</id>
	<title>OpenVZ Virtuozzo Containers Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.openvz.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Hvdkamer"/>
	<link rel="alternate" type="text/html" href="https://wiki.openvz.org/Special:Contributions/Hvdkamer"/>
	<updated>2026-06-10T01:18:49Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.31.1</generator>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=2353</id>
		<title>Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=2353"/>
		<updated>2006-09-29T09:13:39Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* Other applications */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{roughstub}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== The problem ==&lt;br /&gt;
&lt;br /&gt;
One of the problems with shared webhosting (i.e. different people with each his/her own webpages) is that modern script languages such as PHP, Python or Perl are to powerfull. For example take the following PHP script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function get_content($filename) {&lt;br /&gt;
  $handle = fopen($filename, 'r');&lt;br /&gt;
  echo fread($handle, filesize($filename));&lt;br /&gt;
  fclose($handle);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
get_content('/home/ppuk34/www/forum/config.inc.php');&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With PHP you could use open_basedir to prevent this, but there are more ways. For example [http://mgeisler.net/php-shell/ PHP Shell], a script that is [http://mgeisler.net/downloads/phpshell/SECURITY often mis-used] by people with not-so-good intentions. Or think about the [http://www.f-secure.com/v-descs/santy_a.shtml Santy-worm] which mis-used phpBB. Again there is a solution in the form of safe_mode, but lots of PHP scripts break if you enable this. For Python, Perl or CGI-scripts there are no easy ways and you have to use wrappers or other tricks to chroot these.&lt;br /&gt;
&lt;br /&gt;
== The solution ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Shared hosting1.png|345px|right|The OpenVZ way of shared webhosting]]&lt;br /&gt;
&lt;br /&gt;
You can waste hours of time in securing all the possible things you don't want in your shared webhosting environment. And unless you are very familiar with all the things modern scripting languages can do, you probably miss dozens of alternative routes. In this process you frustrate your clients, because security always means that legitimate things break. As a side effect of your hard work, you can waste hours of extra time in educating your users. But in the end most users don't care about security, unless they are themselve victims of a comprimised host. Learning the hard way is by far the most effective method. One possible solution is dedicated webhosting, but most users don't have the experience to maintain a server or it is way to expensicve for them.&lt;br /&gt;
&lt;br /&gt;
The main problem with shared webhosting is that by its very nature all files which are served through the web are public. Apache for example uses only one account to read alle files. As said, you can use tricks with CGI wrappers to execute the scripting languages under its own credentials. However this kind of security depends on the wrappers ability to securely seperate the users. We all know that if this is broken &amp;amp;mdash; and most often it will be broken &amp;amp;mdash; the result is a higher clearance on the underlying filesystem. For most systems you need more than one wrapper, so the number of possible security problems grow. The ultimate user separation is in the kernel and you can view the modifications OpenVZ has done in this light. Instead of CGI wrappers we go one step higher and give every user its own minimal server. In the rest of this article we describe how shared webhosting with OpenVZ could be implemented.&lt;br /&gt;
&lt;br /&gt;
=== Minimal server ===&lt;br /&gt;
&lt;br /&gt;
Create an VEx with your favorite distro. Give it an internal IP-address in one of the ranges 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Then strip away all unessary init.d scripts so only the bare minimum is started. That means as a minimum syslogd and ssh so the account holder can upload his/her files through SCP/SFTP in his/her own minimal server. For this to work you need to set up [[Using NAT for VE with private IPs|destination NAT on VE0]] from high numbered ports to port 22 on the given private IP address:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The other thing you want for webhosting is of course a webserver as well. To minimize the amount of needed memory, we choose [http://www.lighttpd.net/ Lighttpd] instead of the common Apache. Then configure the scripting language of your choice to run under this webserver. It is possible to use different languages/setups for different accounts as well. Also problematic CGI-scripts are not problematic anymore...&lt;br /&gt;
&lt;br /&gt;
=== MySQL server ===&lt;br /&gt;
&lt;br /&gt;
Most webhosting accounts use MySQL, but if you prefer another database server, go ahead. Create a new VEx with a lot more resources and again an internal IP-address. Now configure the accounts. As an extra security measure you can use the internal IP-address as well.&lt;br /&gt;
&lt;br /&gt;
=== Proxy webserver ===&lt;br /&gt;
&lt;br /&gt;
Because we have only one public IP-address, we need an trick to access every minimal server based on the hostname in the HTTP request. For SSH we used different ports, but that is not an option for websites. Again we create an VEx with an internal IP-address. On this server we install Lighttpd as well, because the proxying is very simple. If someone has an working example with Apache, please add. First we must forward port 80 to this server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP -d &amp;amp;lt;external IP-address&amp;gt; --dport 80 $dnat 192.168.13.11:80&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we create for every website an section in /etc/lighttpd/lighttpd.conf as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$HTTP[&amp;quot;host&amp;quot;] == &amp;quot;ve101.armorica.tk&amp;quot; {&lt;br /&gt;
  proxy.server  = ( &amp;quot;&amp;quot; =&amp;gt; ( ( &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;192.168.13.101&amp;quot; ) ) )&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can map more names to the same IP-address if needed. The last step is to add mod_proxy to the server.modules section.&lt;br /&gt;
&lt;br /&gt;
=== Other applications ===&lt;br /&gt;
&lt;br /&gt;
Create for other applications as mail, make sure that the minimal servers use this one for sending mail from webpages, DNS etc. VEx as needed. The resulting server is shown in the figure above.&lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Processes_scope_and_visibility&amp;diff=2166</id>
		<title>Processes scope and visibility</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Processes_scope_and_visibility&amp;diff=2166"/>
		<updated>2006-09-04T09:19:03Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* &amp;quot;Poor man's vzps in bash&amp;quot; */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This [[:Category:HOWTO|HOWTO]] shows how OpenVZ [[hardware node]] administrator can see a processes belonging to the host system only, or to a particular [[VE]].&lt;br /&gt;
&lt;br /&gt;
== Problem ==&lt;br /&gt;
From [[VE0]] one can see all the processes running on the system; that includes all the processes of all [[VE]]s and the processes of the [[host system]] itself. Sometimes you just want to see the processes from the host system only. Sometimes you just want to see the processes from a particular VE.&lt;br /&gt;
&lt;br /&gt;
There are many ways to achieve it.&lt;br /&gt;
&lt;br /&gt;
== Solutions ==&lt;br /&gt;
&lt;br /&gt;
=== &amp;quot;Poor man's vzps in bash&amp;quot; ===&lt;br /&gt;
Use the following script by aistis, modified by kir.&lt;br /&gt;
&lt;br /&gt;
First argument is VE ID (0 for the host system), all the remaining arguments are passed to &amp;lt;code&amp;gt;ps(1)&amp;lt;/code&amp;gt; utility.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/bash&lt;br /&gt;
# Usage: ./ovzps VEID [ps flags ...]&lt;br /&gt;
&lt;br /&gt;
function find_ve_pids(){&lt;br /&gt;
       local pid&lt;br /&gt;
       local myveid=$1&lt;br /&gt;
       local vepids=&lt;br /&gt;
&lt;br /&gt;
       for pid in $ALLPIDS; do&lt;br /&gt;
               [ -f /proc/$pid/status ] || continue&lt;br /&gt;
               veid=`grep envID /proc/$pid/status | awk -F: '{print $2}'`&lt;br /&gt;
               if [ ${veid} = ${myveid} ]; then&lt;br /&gt;
                       vepids=&amp;quot;$vepids $pid&amp;quot;&lt;br /&gt;
               fi&lt;br /&gt;
       done&lt;br /&gt;
       echo &amp;quot;$vepids&amp;quot;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
ALLPIDS=`ps -A -o pid --no-headers`&lt;br /&gt;
VEPIDS=`find_ve_pids $1`&lt;br /&gt;
shift&lt;br /&gt;
&lt;br /&gt;
if [ -n &amp;quot;${VEPIDS}&amp;quot; ]; then&lt;br /&gt;
        ps $* -p $VEPIDS&lt;br /&gt;
else&lt;br /&gt;
        exit 0&lt;br /&gt;
fi&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Use vzprocps tools ===&lt;br /&gt;
Take &amp;lt;code&amp;gt;vzprocps&amp;lt;/code&amp;gt; tools from http://download.openvz.org/contrib/utils/.&lt;br /&gt;
These are usual &amp;lt;code&amp;gt;ps&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;top&amp;lt;/code&amp;gt; utilities (named &amp;lt;code&amp;gt;vztop&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;vzps&amp;lt;/code&amp;gt; to not conflict with the standard ones) with an &amp;lt;code&amp;gt;-E&amp;lt;/code&amp;gt; option added. You can use &amp;lt;code&amp;gt;-E &amp;lt;i&amp;gt;VEID&amp;lt;/i&amp;gt;&amp;lt;/code&amp;gt; option to limit the output to the selected VEID (use 0 for the host system), or just &amp;lt;code&amp;gt;-E&amp;lt;/code&amp;gt; without an argument to just add VEID column to output.&lt;br /&gt;
&lt;br /&gt;
== See also ==&lt;br /&gt;
* {{Forum|836}}&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=UBC_consistency_check&amp;diff=2151</id>
		<title>UBC consistency check</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=UBC_consistency_check&amp;diff=2151"/>
		<updated>2006-08-30T14:54:02Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{UBC toc}}&lt;br /&gt;
&lt;br /&gt;
System resource control parameters have certain interdependencies. Constraints on the parameter settings are listed below. Indexes &amp;lt;code&amp;gt;bar&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;lim&amp;lt;/code&amp;gt; in the formulae below mean the barrier and the limit of the parameters, respectively.&lt;br /&gt;
&lt;br /&gt;
Configuration of resource control parameters for a Virtual Environment&lt;br /&gt;
is invalid if these constraints are not satisfied. The best way to ensure the&lt;br /&gt;
validity of the configuration is to use [http://openvz.org/documentation/man/vzcfgvalidate.8 vzcfgvalidate(8)] utility.&lt;br /&gt;
&lt;br /&gt;
All the interdependencies discussed below and their importance are summarized in [[UBC interdependencies table]].&lt;br /&gt;
&lt;br /&gt;
The configured limits can be checked through&lt;br /&gt;
* &amp;lt;code&amp;gt;/proc/user beancounters&amp;lt;/code&amp;gt; interface;&lt;br /&gt;
* Virtual Environment configuration files in &amp;lt;code&amp;gt;/etc/vz/conf/&amp;lt;/code&amp;gt; directory.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== kmemsize should be enough for the expected number of processes ==&lt;br /&gt;
&amp;lt;math&amp;gt;kmemsize_{bar} \ge 40KB \cdot avnumproc + dcachesize_{lim}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
(&amp;lt;code&amp;gt;avnumproc&amp;lt;/code&amp;gt; here stands for the expected average number of processes).&lt;br /&gt;
&lt;br /&gt;
This constraint is important for reliable work of applications in the&lt;br /&gt;
Virtual Environment.&lt;br /&gt;
If it is not satisfied, applications will start to fail at the middle of&lt;br /&gt;
operations instead of failing at the moment of spawning more processes,&lt;br /&gt;
and the application abilities to handle resource shortage will be very&lt;br /&gt;
limited.&lt;br /&gt;
&lt;br /&gt;
== Memory allocation limits should not be less than the guarantee ==&lt;br /&gt;
&amp;lt;math&amp;gt; privvmpages_{bar} \ge vmguarpages_{bar}&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
If this constraint is not satisfied, &amp;lt;code&amp;gt;vmguarpages&amp;lt;/code&amp;gt; will not work.&lt;br /&gt;
&lt;br /&gt;
== Send buffers should have enough space for all sockets ==&lt;br /&gt;
&amp;lt;math&amp;gt;tcpsndbuf_{lim} - tcpsndbuf_{bar} \ge 2.5KB \cdot numtcpsock&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;othersockbuf_{lim} - othersockbuf_{bar} \ge 2.5KB \cdot numothersock&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These constraints are also important.&lt;br /&gt;
If they are not satisfied, transmission of data over the sockets&lt;br /&gt;
may hang in some circumstances.&lt;br /&gt;
&lt;br /&gt;
== Other TCP socket buffers should be big enough ==&lt;br /&gt;
&amp;lt;math&amp;gt;tcprcvbuf_{lim} - tcprcvbuf_{bar} \ge 2.5KB \cdot numtcpsock&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;tcprcvbuf_{bar} \ge 64KB&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;tcpsndbuf_{bar} \ge 64KB&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Selecting the left side equal to the right side in the inequalities&lt;br /&gt;
above ensures minimal performance of network communications.&lt;br /&gt;
Increasing the left side will increase performance to certain extent.&lt;br /&gt;
&lt;br /&gt;
== UDP socket buffers should be big enough if the system is not tight on memory ==&lt;br /&gt;
&amp;lt;math&amp;gt;dgramrcvbuf_{bar} \ge 129KB&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;othersockbuf_{bar} \ge 129KB&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
These constraints are desired, but not essential.&lt;br /&gt;
Big enough buffers for UDP sockets improve reliability of datagram delivery.&lt;br /&gt;
However, note that if the UDP traffic is so bursty that it needs larger&lt;br /&gt;
buffers, the datagrams will likely be lost not because of resource control&lt;br /&gt;
limits, but because of other memory and performance limitations.&lt;br /&gt;
&lt;br /&gt;
== Number of file limit should be adequate for the expected number of processes ==&lt;br /&gt;
&amp;lt;math&amp;gt;numfile \ge avnumproc \cdot 32&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note that each process after &amp;lt;code&amp;gt;execve(2)&amp;lt;/code&amp;gt; system call&lt;br /&gt;
requires a file for each loaded shared library.&lt;br /&gt;
Too low &amp;lt;code&amp;gt;numfile&amp;lt;/code&amp;gt; limit will increase the chances of failures&lt;br /&gt;
during &amp;lt;code&amp;gt;execve(2)&amp;lt;/code&amp;gt; call with diagnostics not clear&lt;br /&gt;
for the users.&lt;br /&gt;
&lt;br /&gt;
== The limit on the total size of &amp;lt;code&amp;gt;dentry&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;inode&amp;lt;/code&amp;gt; structures locked in memory should be adequate for allowed number of files ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;dcachesize_{bar} \ge numfile \cdot 384\ \rm(bytes)&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Too low &amp;lt;code&amp;gt;dcachesize&amp;lt;/code&amp;gt; limit will increase the chances of&lt;br /&gt;
file operation refusals not expected by applications.&lt;br /&gt;
&lt;br /&gt;
== Barrier should be less or equal than limit ==&lt;br /&gt;
In addition to the conditions listed above,&lt;br /&gt;
&lt;br /&gt;
&amp;lt;math&amp;gt;barrier \le limit&amp;lt;/math&amp;gt;&lt;br /&gt;
&lt;br /&gt;
should be maintained for each parameter.&lt;br /&gt;
&lt;br /&gt;
[[Category:Troubleshooting]]&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Resource_shortage&amp;diff=1985</id>
		<title>Resource shortage</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Resource_shortage&amp;diff=1985"/>
		<updated>2006-08-17T11:04:35Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Sometimes you see a strange fails from some programs inside your [[VE|Virtual Environment]]. In some cases it means one of the resources controlled by OpenVZ hit the limit.&lt;br /&gt;
&lt;br /&gt;
The first thing to do is to check the contents of /proc/user_beancounters file in your [[VE]]. The last column of output is fail counter. Each time a resource hit the limit, fail counter is increasing. So, if you see non-zero values in failcnt column that means something is wrong.&lt;br /&gt;
&lt;br /&gt;
There are two ways to fix the situation: reconfigure (in some cases recompile) the application, or change the resource management settings.&lt;br /&gt;
&lt;br /&gt;
== [[UBC]] parameters ==&lt;br /&gt;
&lt;br /&gt;
Here is the example of current [[UBC]] values obtained from &amp;lt;code&amp;gt;/proc/user_beancounters&amp;lt;/code&amp;gt; file in VE 123:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# cat /proc/user_beancounters&lt;br /&gt;
Version: 2.5&lt;br /&gt;
       uid  resource           held    maxheld    barrier      limit    failcnt&lt;br /&gt;
       123: kmemsize         836919    1005343    2752512    2936012          0&lt;br /&gt;
            lockedpages           0          0         32         32          0&lt;br /&gt;
            privvmpages        4587       7289      49152      53575          0&lt;br /&gt;
            shmpages             39         39       8192       8192          0&lt;br /&gt;
            dummy                 0          0          0          0          0&lt;br /&gt;
            numproc              20         26         65         65          0&lt;br /&gt;
            physpages          2267       2399          0 2147483647          0&lt;br /&gt;
            vmguarpages           0          0       6144 2147483647          0&lt;br /&gt;
            oomguarpages       2267       2399       6144 2147483647          0&lt;br /&gt;
            numtcpsock            3          3         80         80          0&lt;br /&gt;
            numflock              3          4        100        110          0&lt;br /&gt;
            numpty                1          1         16         16          0&lt;br /&gt;
            numsiginfo            0          1        256        256          0&lt;br /&gt;
            tcpsndbuf             0          0     319488     524288          0&lt;br /&gt;
            tcprcvbuf             0          0     319488     524288          0&lt;br /&gt;
            othersockbuf       6684       7888     132096     336896          0&lt;br /&gt;
            dgramrcvbuf           0       8372     132096     132096          0&lt;br /&gt;
            numothersock          8         10         80         80          0&lt;br /&gt;
            dcachesize        87672      92168    1048576    1097728          0&lt;br /&gt;
            numfile             238        306       2048       2048          0&lt;br /&gt;
            dummy                 0          0          0          0          0&lt;br /&gt;
            dummy                 0          0          0          0          0&lt;br /&gt;
            dummy                 0          0          0          0          0&lt;br /&gt;
            numiptent            10         16        128        128          0&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can see if you hit the limits for some [[UBC]] parameters by analyzing the last column (named &amp;lt;code&amp;gt;failcnt&amp;lt;/code&amp;gt;). It shows a number of fails for this counter, i.e. a number of times a parameter hit the limit. Usually what you need to do is to increase the parameter in question. But you need to do it carefully, and here is how.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Get the current values for the parameter's barrier and limit. For example, we want to increase kmemsize values from the example at . From &amp;lt;code&amp;gt;/proc/user_beancounters&amp;lt;/code&amp;gt; we see that &amp;lt;code&amp;gt;kmemsize&amp;lt;/code&amp;gt; barrier is 2752512, and its limit is 2936012.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Increase the values. Say, we want to increase &amp;lt;code&amp;gt;kmemsize&amp;lt;/code&amp;gt; by 2 times. This is how it can be done using built-in bash arithmetics:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl set 123 --kmemsize $((2752512*2)):$((2936012*2)) --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
By using &amp;lt;code&amp;gt;--save&amp;lt;/code&amp;gt; flag, we denote we want to both apply the new settings to the running VE, and save them in the configuration file (from which they will be taken during next VE start).&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;Check the new configuration. Issue the following command:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzcfgvalidate /etc/vz/conf/123.conf&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
If something is wrong, you need to fix it as suggested by the utility.&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
For more in-depth explanation of different parameters, their meaning and how to set them properly, see [[setting UBC parameters]].&lt;br /&gt;
&lt;br /&gt;
== Disk quota ==&lt;br /&gt;
To check if your [[VE]] ran out of its disk quota, use the following commands (inside a VE):&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# df&lt;br /&gt;
Filesystem           1K-blocks      Used Available Use% Mounted on&lt;br /&gt;
simfs                  1048576    327664    720912  32% /&lt;br /&gt;
# df -i&lt;br /&gt;
Filesystem            Inodes   IUsed   IFree IUse% Mounted on&lt;br /&gt;
simfs                 200000   18857  181143   10% /&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
First command shows disk space usage, and second command shows the inodes usage (you can roughly see inodes as a number of files/directories on your system).&lt;br /&gt;
&lt;br /&gt;
If one of the commands give you usage of 100%, that means you hit one of the disk quota limit. &lt;br /&gt;
&lt;br /&gt;
You can increase the limit from the host system ([[VE0]]) only. This is how:&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
&amp;lt;li&amp;gt;Get the current values for disk quota:&lt;br /&gt;
&amp;lt;pre&amp;gt;# vzquota stat 123&lt;br /&gt;
   resource          usage       softlimit      hardlimit    grace&lt;br /&gt;
  1k-blocks         327664         1048576        1153434&lt;br /&gt;
     inodes          18857          200000         220000&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;To increase the disk space quota, use vzctl set --diskspace. For example, we want to increase it by a factor of 2:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 123 --diskspace $(( 1048576*2 )):$(( 1153434*2 )) --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;li&amp;gt;To increase the disk inodes quota, use &amp;lt;tt&amp;gt;vzctl set --diskinodes&amp;lt;/tt&amp;gt;. For example, we want to increase it by a factor of 3:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
vzctl set 123 --diskinodes $(( 200000*3 )):$(( 220000*3 )) --save&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|shell does not support floating-point arithmetics, i.e. you can not use expressions like &amp;lt;code&amp;gt;$((&amp;amp;nbsp;220000*1.5&amp;amp;nbsp;))&amp;lt;/code&amp;gt;. To use floating point, try &amp;lt;code&amp;gt;bc&amp;lt;/code&amp;gt; instead, something like this: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;$(echo&amp;amp;nbsp;220000*1.5&amp;amp;nbsp;|&amp;amp;nbsp;bc)&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;.}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Troubleshooting]]&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=UBC_parameter_units&amp;diff=1984</id>
		<title>UBC parameter units</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=UBC_parameter_units&amp;diff=1984"/>
		<updated>2006-08-17T11:02:13Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* Overriding default units */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== UBC default units ==&lt;br /&gt;
&lt;br /&gt;
# entries which name has word 'page' are measured in memory pages (4kb on x86 and x86-64, 16kb for IA64). These are privvmpages, oomguarpages and others.&lt;br /&gt;
# entries with names like 'num*' are measured in items. i.e. numproc - number of processes, numiptent - number of iptables entries.&lt;br /&gt;
# other entries like kmemsize, tcprcvbuf/tcpsndbuf are measured in bytes &lt;br /&gt;
&lt;br /&gt;
== Overriding default units ==&lt;br /&gt;
&lt;br /&gt;
You can set parameter units implicitly when appropriate, for example:&lt;br /&gt;
&lt;br /&gt;
* Set kmemsize limit to 512 Kb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl set --kmemsize 512k&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Set privvmpages limit to 256 Mb&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl set --privvmpages 256m&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Set tcprcvbuf limit to 1000 pages (totals to almost 4 Mb on x86)&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# vzctl set --tcprcvbuf 1000p&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1949</id>
		<title>Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1949"/>
		<updated>2006-08-03T09:41:46Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* The problem */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''Note: This article is not finished and at the moment a rough draft. Please modify :-)'''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== The problem ==&lt;br /&gt;
&lt;br /&gt;
One of the problems with shared webhosting (i.e. different people with each his/her own webpages) is that modern script languages such as PHP, Python or Perl are to powerfull. For example take the following PHP script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function get_content($filename) {&lt;br /&gt;
  $handle = fopen($filename, 'r');&lt;br /&gt;
  echo fread($handle, filesize($filename));&lt;br /&gt;
  fclose($handle);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
get_content('/home/ppuk34/www/forum/config.inc.php');&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With PHP you could use open_basedir to prevent this, but there are more ways. For example [http://mgeisler.net/php-shell/ PHP Shell], a script that is [http://mgeisler.net/downloads/phpshell/SECURITY often mis-used] by people with not-so-good intentions. Or think about the [http://www.f-secure.com/v-descs/santy_a.shtml Santy-worm] which mis-used phpBB. Again there is a solution in the form of safe_mode, but lots of PHP scripts break if you enable this. For Python, Perl or CGI-scripts there are no easy ways and you have to use wrappers or other tricks to chroot these.&lt;br /&gt;
&lt;br /&gt;
== The solution ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Shared hosting1.png|345px|right|The OpenVZ way of shared webhosting]]&lt;br /&gt;
&lt;br /&gt;
You can waste hours of time in securing all the possible things you don't want in your shared webhosting environment. And unless you are very familiar with all the things modern scripting languages can do, you probably miss dozens of alternative routes. In this process you frustrate your clients, because security always means that legitimate things break. As a side effect of your hard work, you can waste hours of extra time in educating your users. But in the end most users don't care about security, unless they are themselve victims of a comprimised host. Learning the hard way is by far the most effective method. One possible solution is dedicated webhosting, but most users don't have the experience to maintain a server or it is way to expensicve for them.&lt;br /&gt;
&lt;br /&gt;
The main problem with shared webhosting is that by its very nature all files which are served through the web are public. Apache for example uses only one account to read alle files. As said, you can use tricks with CGI wrappers to execute the scripting languages under its own credentials. However this kind of security depends on the wrappers ability to securely seperate the users. We all know that if this is broken &amp;amp;mdash; and most often it will be broken &amp;amp;mdash; the result is a higher clearance on the underlying filesystem. For most systems you need more than one wrapper, so the number of possible security problems grow. The ultimate user separation is in the kernel and you can view the modifications OpenVZ has done in this light. Instead of CGI wrappers we go one step higher and give every user its own minimal server. In the rest of this article we describe how shared webhosting with OpenVZ could be implemented.&lt;br /&gt;
&lt;br /&gt;
=== Minimal server ===&lt;br /&gt;
&lt;br /&gt;
Create an VEx with your favorite distro. Give it an internal IP-address in one of the ranges 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Then strip away all unessary init.d scripts so only the bare minimum is started. That means as a minimum syslogd and ssh so the account holder can upload his/her files through SCP/SFTP in his/her own minimal server. For this to work you need to set up [[Using NAT for VE with private IPs|destination NAT on VE0]] from high numbered ports to port 22 on the given private IP address:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The other thing you want for webhosting is of course a webserver as well. To minimize the amount of needed memory, we choose [http://www.lighttpd.net/ Lighttpd] instead of the common Apache. Then configure the scripting language of your choice to run under this webserver. It is possible to use different languages/setups for different accounts as well. Also problematic CGI-scripts are not problematic anymore...&lt;br /&gt;
&lt;br /&gt;
=== MySQL server ===&lt;br /&gt;
&lt;br /&gt;
Most webhosting accounts use MySQL, but if you prefer another database server, go ahead. Create a new VEx with a lot more resources and again an internal IP-address. Now configure the accounts. As an extra security measure you can use the internal IP-address as well.&lt;br /&gt;
&lt;br /&gt;
=== Proxy webserver ===&lt;br /&gt;
&lt;br /&gt;
Because we have only one public IP-address, we need an trick to access every minimal server based on the hostname in the HTTP request. For SSH we used different ports, but that is not an option for websites. Again we create an VEx with an internal IP-address. On this server we install Lighttpd as well, because the proxying is very simple. If someone has an working example with Apache, please add. First we must forward port 80 to this server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP -d &amp;amp;lt;external IP-address&amp;gt; --dport 80 $dnat 192.168.13.11:80&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we create for every website an section in /etc/lighttpd/lighttpd.conf as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$HTTP[&amp;quot;host&amp;quot;] == &amp;quot;ve101.armorica.tk&amp;quot; {&lt;br /&gt;
  proxy.server  = ( &amp;quot;&amp;quot; =&amp;gt; ( ( &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;192.168.13.101&amp;quot; ) ) )&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can map more names to the same IP-address if needed. The last step is to add mod_proxy to the server.modules section.&lt;br /&gt;
&lt;br /&gt;
=== Other applications ===&lt;br /&gt;
&lt;br /&gt;
Create for other applications as mail, make sure that the minimal servers use this one for sending mail from webpages, DNS etc. VEx as needed. The resulting sever looks something lik this:&lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1948</id>
		<title>Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1948"/>
		<updated>2006-08-03T09:40:10Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* The solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== The problem ==&lt;br /&gt;
&lt;br /&gt;
'''Note: this is my first try to create an Wiki article. Please modify :-)'''&lt;br /&gt;
&lt;br /&gt;
One of the problems with shared webhosting (i.e. different people with each his/her own webpages) is that modern script languages such as PHP, Python or Perl are to powerfull. For example take the following PHP script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function get_content($filename) {&lt;br /&gt;
  $handle = fopen($filename, 'r');&lt;br /&gt;
  echo fread($handle, filesize($filename));&lt;br /&gt;
  fclose($handle);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
get_content('/home/ppuk34/www/forum/config.inc.php');&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With PHP you could use open_basedir to prevent this, but there are more ways. For example [http://mgeisler.net/php-shell/ PHP Shell], a script that is [http://mgeisler.net/downloads/phpshell/SECURITY often mis-used] by people with not-so-good intentions. Or think about the [http://www.f-secure.com/v-descs/santy_a.shtml Santy-worm] which mis-used phpBB. Again there is a solution in the form of safe_mode, but lots of PHP scripts break if you enable this. For Python, Perl or CGI-scripts there are no easy ways and you have to use wrappers or other tricks to chroot these.&lt;br /&gt;
&lt;br /&gt;
== The solution ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Shared hosting1.png|345px|right|The OpenVZ way of shared webhosting]]&lt;br /&gt;
&lt;br /&gt;
You can waste hours of time in securing all the possible things you don't want in your shared webhosting environment. And unless you are very familiar with all the things modern scripting languages can do, you probably miss dozens of alternative routes. In this process you frustrate your clients, because security always means that legitimate things break. As a side effect of your hard work, you can waste hours of extra time in educating your users. But in the end most users don't care about security, unless they are themselve victims of a comprimised host. Learning the hard way is by far the most effective method. One possible solution is dedicated webhosting, but most users don't have the experience to maintain a server or it is way to expensicve for them.&lt;br /&gt;
&lt;br /&gt;
The main problem with shared webhosting is that by its very nature all files which are served through the web are public. Apache for example uses only one account to read alle files. As said, you can use tricks with CGI wrappers to execute the scripting languages under its own credentials. However this kind of security depends on the wrappers ability to securely seperate the users. We all know that if this is broken &amp;amp;mdash; and most often it will be broken &amp;amp;mdash; the result is a higher clearance on the underlying filesystem. For most systems you need more than one wrapper, so the number of possible security problems grow. The ultimate user separation is in the kernel and you can view the modifications OpenVZ has done in this light. Instead of CGI wrappers we go one step higher and give every user its own minimal server. In the rest of this article we describe how shared webhosting with OpenVZ could be implemented.&lt;br /&gt;
&lt;br /&gt;
=== Minimal server ===&lt;br /&gt;
&lt;br /&gt;
Create an VEx with your favorite distro. Give it an internal IP-address in one of the ranges 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Then strip away all unessary init.d scripts so only the bare minimum is started. That means as a minimum syslogd and ssh so the account holder can upload his/her files through SCP/SFTP in his/her own minimal server. For this to work you need to set up [[Using NAT for VE with private IPs|destination NAT on VE0]] from high numbered ports to port 22 on the given private IP address:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The other thing you want for webhosting is of course a webserver as well. To minimize the amount of needed memory, we choose [http://www.lighttpd.net/ Lighttpd] instead of the common Apache. Then configure the scripting language of your choice to run under this webserver. It is possible to use different languages/setups for different accounts as well. Also problematic CGI-scripts are not problematic anymore...&lt;br /&gt;
&lt;br /&gt;
=== MySQL server ===&lt;br /&gt;
&lt;br /&gt;
Most webhosting accounts use MySQL, but if you prefer another database server, go ahead. Create a new VEx with a lot more resources and again an internal IP-address. Now configure the accounts. As an extra security measure you can use the internal IP-address as well.&lt;br /&gt;
&lt;br /&gt;
=== Proxy webserver ===&lt;br /&gt;
&lt;br /&gt;
Because we have only one public IP-address, we need an trick to access every minimal server based on the hostname in the HTTP request. For SSH we used different ports, but that is not an option for websites. Again we create an VEx with an internal IP-address. On this server we install Lighttpd as well, because the proxying is very simple. If someone has an working example with Apache, please add. First we must forward port 80 to this server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP -d &amp;amp;lt;external IP-address&amp;gt; --dport 80 $dnat 192.168.13.11:80&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we create for every website an section in /etc/lighttpd/lighttpd.conf as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$HTTP[&amp;quot;host&amp;quot;] == &amp;quot;ve101.armorica.tk&amp;quot; {&lt;br /&gt;
  proxy.server  = ( &amp;quot;&amp;quot; =&amp;gt; ( ( &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;192.168.13.101&amp;quot; ) ) )&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can map more names to the same IP-address if needed. The last step is to add mod_proxy to the server.modules section.&lt;br /&gt;
&lt;br /&gt;
=== Other applications ===&lt;br /&gt;
&lt;br /&gt;
Create for other applications as mail, make sure that the minimal servers use this one for sending mail from webpages, DNS etc. VEx as needed. The resulting sever looks something lik this:&lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1947</id>
		<title>Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1947"/>
		<updated>2006-08-03T09:35:26Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* The problem */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== The problem ==&lt;br /&gt;
&lt;br /&gt;
'''Note: this is my first try to create an Wiki article. Please modify :-)'''&lt;br /&gt;
&lt;br /&gt;
One of the problems with shared webhosting (i.e. different people with each his/her own webpages) is that modern script languages such as PHP, Python or Perl are to powerfull. For example take the following PHP script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function get_content($filename) {&lt;br /&gt;
  $handle = fopen($filename, 'r');&lt;br /&gt;
  echo fread($handle, filesize($filename));&lt;br /&gt;
  fclose($handle);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
get_content('/home/ppuk34/www/forum/config.inc.php');&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With PHP you could use open_basedir to prevent this, but there are more ways. For example [http://mgeisler.net/php-shell/ PHP Shell], a script that is [http://mgeisler.net/downloads/phpshell/SECURITY often mis-used] by people with not-so-good intentions. Or think about the [http://www.f-secure.com/v-descs/santy_a.shtml Santy-worm] which mis-used phpBB. Again there is a solution in the form of safe_mode, but lots of PHP scripts break if you enable this. For Python, Perl or CGI-scripts there are no easy ways and you have to use wrappers or other tricks to chroot these.&lt;br /&gt;
&lt;br /&gt;
== The solution ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Shared hosting1.png|345px|right|The OpenVZ way of shared webhosting]]&lt;br /&gt;
&lt;br /&gt;
As said, you can waste hours of time in securing all the possible things you don't want in your shared webhosting environment. And unless you are very familiar with all the things modern scripting languages can do, you pronbably miss dozens of alternative routes. In this process you frustrate your clients, because security always means that legitimate things break. As a side effect of your hard work, you can waste hours of extra time in educating your users. But in the end most users don't care about security, unless they are themselve victims of a comprimised host. Learning the hard way is by far the most effective method.&lt;br /&gt;
&lt;br /&gt;
Instead of the above route, we take a different approach. The main problem is that by its very nature all files which are served through the web are public. Apache for example uses only one account to read alle files. As said, you can use tricks with CGI wrappers to execute the scripting languages under its own credentials. However this kind of security depends on the wrappers ability to securely seperate the users. We all know that if this is broken &amp;amp;mdash; and most often it will be broken &amp;amp;mdash; the result is a higher clearance on the underlying filesystem. For most systems you need more than one wrapper, so the number of possible security problems grow. The ultimate user separation is in the kernel and you can view the modifications OpenVZ has done in this light. Instead of CGI wrappers we go one step higher and give every user its own minimal server. In the rest of this article we describe how shared webhosting with OpenVZ could be implemented.&lt;br /&gt;
&lt;br /&gt;
=== Minimal server ===&lt;br /&gt;
&lt;br /&gt;
Create an VEx with your favorite distro. Give it an internal IP-address in one of the ranges 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Then strip away all unessary init.d scripts so only the bare minimum is started. That means as a minimum syslogd and ssh so the account holder can upload his/her files through SCP/SFTP in his/her own minimal server. For this to work you need to set up [[Using NAT for VE with private IPs|destination NAT on VE0]] from high numbered ports to port 22 on the given private IP address:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The other thing you want for webhosting is of course a webserver as well. To minimize the amount of needed memory, we choose [http://www.lighttpd.net/ Lighttpd] instead of the common Apache. Then configure the scripting language of your choice to run under this webserver. It is possible to use different languages/setups for different accounts as well. Also problematic CGI-scripts are not problematic anymore...&lt;br /&gt;
&lt;br /&gt;
=== MySQL server ===&lt;br /&gt;
&lt;br /&gt;
Most webhosting accounts use MySQL, but if you prefer another database server, go ahead. Create a new VEx with a lot more resources and again an internal IP-address. Now configure the accounts. As an extra security measure you can use the internal IP-address as well.&lt;br /&gt;
&lt;br /&gt;
=== Proxy webserver ===&lt;br /&gt;
&lt;br /&gt;
Because we have only one public IP-address, we need an trick to access every minimal server based on the hostname in the HTTP request. For SSH we used different ports, but that is not an option for websites. Again we create an VEx with an internal IP-address. On this server we install Lighttpd as well, because the proxying is very simple. If someone has an working example with Apache, please add. First we must forward port 80 to this server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP -d &amp;amp;lt;external IP-address&amp;gt; --dport 80 $dnat 192.168.13.11:80&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we create for every website an section in /etc/lighttpd/lighttpd.conf as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$HTTP[&amp;quot;host&amp;quot;] == &amp;quot;ve101.armorica.tk&amp;quot; {&lt;br /&gt;
  proxy.server  = ( &amp;quot;&amp;quot; =&amp;gt; ( ( &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;192.168.13.101&amp;quot; ) ) )&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can map more names to the same IP-address if needed. The last step is to add mod_proxy to the server.modules section.&lt;br /&gt;
&lt;br /&gt;
=== Other applications ===&lt;br /&gt;
&lt;br /&gt;
Create for other applications as mail, make sure that the minimal servers use this one for sending mail from webpages, DNS etc. VEx as needed. The resulting sever looks something lik this:&lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1946</id>
		<title>Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1946"/>
		<updated>2006-08-03T09:32:05Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* The solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== The problem ==&lt;br /&gt;
&lt;br /&gt;
'''Note: this is my first try to create an Wiki article. Please modify :-)'''&lt;br /&gt;
&lt;br /&gt;
One of the problems with shared webhosting (i.e. different people with each his/her own webpages) is that modern script languages such as PHP, Python or Perl are to powerfull. For example take the following PHP script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function get_content($filename) {&lt;br /&gt;
  $handle = fopen($filename, 'r');&lt;br /&gt;
  echo fread($handle, filesize($filename));&lt;br /&gt;
  fclose($handle);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
get_content('/home/ppuk34/www/forum/config.inc.php');&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With PHP you could use open_basedir to prevent this, but there are more ways. For example [http://mgeisler.net/php-shell/ PHP Shell], a script that is [http://mgeisler.net/downloads/phpshell/SECURITY often mis-used] by people with not-so-good intentions. Or think about the [http://www.f-secure.com/v-descs/santy_a.shtml Santy-worm] which mis-used phpBB. Again there is a solution in the form of safe_mode, but lots of PHP scripts break if you enable this. For Python, Perl or CGI-scripts there are no easy ways and you have to use wrappers or other tricks to chroot these. Most users don't want to hear about security (unless you show them how easy it is) and just want there scripts to work. Some do care, but his/her own server is much to expensive. And finally we didn't talk about hidden bugs in almost every security measure we mentioned. A knowledgeable person can almost certain find backdoors because of the vast amount of possibilities these scripting languages offer.&lt;br /&gt;
&lt;br /&gt;
== The solution ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Shared hosting1.png|345px|right|The OpenVZ way of shared webhosting]]&lt;br /&gt;
&lt;br /&gt;
As said, you can waste hours of time in securing all the possible things you don't want in your shared webhosting environment. And unless you are very familiar with all the things modern scripting languages can do, you pronbably miss dozens of alternative routes. In this process you frustrate your clients, because security always means that legitimate things break. As a side effect of your hard work, you can waste hours of extra time in educating your users. But in the end most users don't care about security, unless they are themselve victims of a comprimised host. Learning the hard way is by far the most effective method.&lt;br /&gt;
&lt;br /&gt;
Instead of the above route, we take a different approach. The main problem is that by its very nature all files which are served through the web are public. Apache for example uses only one account to read alle files. As said, you can use tricks with CGI wrappers to execute the scripting languages under its own credentials. However this kind of security depends on the wrappers ability to securely seperate the users. We all know that if this is broken &amp;amp;mdash; and most often it will be broken &amp;amp;mdash; the result is a higher clearance on the underlying filesystem. For most systems you need more than one wrapper, so the number of possible security problems grow. The ultimate user separation is in the kernel and you can view the modifications OpenVZ has done in this light. Instead of CGI wrappers we go one step higher and give every user its own minimal server. In the rest of this article we describe how shared webhosting with OpenVZ could be implemented.&lt;br /&gt;
&lt;br /&gt;
=== Minimal server ===&lt;br /&gt;
&lt;br /&gt;
Create an VEx with your favorite distro. Give it an internal IP-address in one of the ranges 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Then strip away all unessary init.d scripts so only the bare minimum is started. That means as a minimum syslogd and ssh so the account holder can upload his/her files through SCP/SFTP in his/her own minimal server. For this to work you need to set up [[Using NAT for VE with private IPs|destination NAT on VE0]] from high numbered ports to port 22 on the given private IP address:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The other thing you want for webhosting is of course a webserver as well. To minimize the amount of needed memory, we choose [http://www.lighttpd.net/ Lighttpd] instead of the common Apache. Then configure the scripting language of your choice to run under this webserver. It is possible to use different languages/setups for different accounts as well. Also problematic CGI-scripts are not problematic anymore...&lt;br /&gt;
&lt;br /&gt;
=== MySQL server ===&lt;br /&gt;
&lt;br /&gt;
Most webhosting accounts use MySQL, but if you prefer another database server, go ahead. Create a new VEx with a lot more resources and again an internal IP-address. Now configure the accounts. As an extra security measure you can use the internal IP-address as well.&lt;br /&gt;
&lt;br /&gt;
=== Proxy webserver ===&lt;br /&gt;
&lt;br /&gt;
Because we have only one public IP-address, we need an trick to access every minimal server based on the hostname in the HTTP request. For SSH we used different ports, but that is not an option for websites. Again we create an VEx with an internal IP-address. On this server we install Lighttpd as well, because the proxying is very simple. If someone has an working example with Apache, please add. First we must forward port 80 to this server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP -d &amp;amp;lt;external IP-address&amp;gt; --dport 80 $dnat 192.168.13.11:80&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we create for every website an section in /etc/lighttpd/lighttpd.conf as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$HTTP[&amp;quot;host&amp;quot;] == &amp;quot;ve101.armorica.tk&amp;quot; {&lt;br /&gt;
  proxy.server  = ( &amp;quot;&amp;quot; =&amp;gt; ( ( &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;192.168.13.101&amp;quot; ) ) )&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can map more names to the same IP-address if needed. The last step is to add mod_proxy to the server.modules section.&lt;br /&gt;
&lt;br /&gt;
=== Other applications ===&lt;br /&gt;
&lt;br /&gt;
Create for other applications as mail, make sure that the minimal servers use this one for sending mail from webpages, DNS etc. VEx as needed. The resulting sever looks something lik this:&lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1945</id>
		<title>Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1945"/>
		<updated>2006-08-03T09:31:22Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* The solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== The problem ==&lt;br /&gt;
&lt;br /&gt;
'''Note: this is my first try to create an Wiki article. Please modify :-)'''&lt;br /&gt;
&lt;br /&gt;
One of the problems with shared webhosting (i.e. different people with each his/her own webpages) is that modern script languages such as PHP, Python or Perl are to powerfull. For example take the following PHP script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function get_content($filename) {&lt;br /&gt;
  $handle = fopen($filename, 'r');&lt;br /&gt;
  echo fread($handle, filesize($filename));&lt;br /&gt;
  fclose($handle);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
get_content('/home/ppuk34/www/forum/config.inc.php');&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With PHP you could use open_basedir to prevent this, but there are more ways. For example [http://mgeisler.net/php-shell/ PHP Shell], a script that is [http://mgeisler.net/downloads/phpshell/SECURITY often mis-used] by people with not-so-good intentions. Or think about the [http://www.f-secure.com/v-descs/santy_a.shtml Santy-worm] which mis-used phpBB. Again there is a solution in the form of safe_mode, but lots of PHP scripts break if you enable this. For Python, Perl or CGI-scripts there are no easy ways and you have to use wrappers or other tricks to chroot these. Most users don't want to hear about security (unless you show them how easy it is) and just want there scripts to work. Some do care, but his/her own server is much to expensive. And finally we didn't talk about hidden bugs in almost every security measure we mentioned. A knowledgeable person can almost certain find backdoors because of the vast amount of possibilities these scripting languages offer.&lt;br /&gt;
&lt;br /&gt;
== The solution ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Shared hosting1.png|360px|right|The OpenVZ way of shared webhosting]]&lt;br /&gt;
&lt;br /&gt;
As said, you can waste hours of time in securing all the possible things you don't want in your shared webhosting environment. And unless you are very familiar with all the things modern scripting languages can do, you pronbably miss dozens of alternative routes. In this process you frustrate your clients, because security always means that legitimate things break. As a side effect of your hard work, you can waste hours of extra time in educating your users. But in the end most users don't care about security, unless they are themselve victims of a comprimised host. Learning the hard way is by far the most effective method.&lt;br /&gt;
&lt;br /&gt;
Instead of the above route, we take a different approach. The main problem is that by its very nature all files which are served through the web are public. Apache for example uses only one account to read alle files. As said, you can use tricks with CGI wrappers to execute the scripting languages under its own credentials. However this kind of security depends on the wrappers ability to securely seperate the users. We all know that if this is broken &amp;amp;mdash; and most often it will be broken &amp;amp;mdash; the result is a higher clearance on the underlying filesystem. For most systems you need more than one wrapper, so the number of possible security problems grow. The ultimate user separation is in the kernel and you can view the modifications OpenVZ has done in this light. Instead of CGI wrappers we go one step higher and give every user its own minimal server. In the rest of this article we describe how shared webhosting with OpenVZ could be implemented.&lt;br /&gt;
&lt;br /&gt;
=== Minimal server ===&lt;br /&gt;
&lt;br /&gt;
Create an VEx with your favorite distro. Give it an internal IP-address in one of the ranges 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Then strip away all unessary init.d scripts so only the bare minimum is started. That means as a minimum syslogd and ssh so the account holder can upload his/her files through SCP/SFTP in his/her own minimal server. For this to work you need to set up [[Using NAT for VE with private IPs|destination NAT on VE0]] from high numbered ports to port 22 on the given private IP address:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The other thing you want for webhosting is of course a webserver as well. To minimize the amount of needed memory, we choose [http://www.lighttpd.net/ Lighttpd] instead of the common Apache. Then configure the scripting language of your choice to run under this webserver. It is possible to use different languages/setups for different accounts as well. Also problematic CGI-scripts are not problematic anymore...&lt;br /&gt;
&lt;br /&gt;
=== MySQL server ===&lt;br /&gt;
&lt;br /&gt;
Most webhosting accounts use MySQL, but if you prefer another database server, go ahead. Create a new VEx with a lot more resources and again an internal IP-address. Now configure the accounts. As an extra security measure you can use the internal IP-address as well.&lt;br /&gt;
&lt;br /&gt;
=== Proxy webserver ===&lt;br /&gt;
&lt;br /&gt;
Because we have only one public IP-address, we need an trick to access every minimal server based on the hostname in the HTTP request. For SSH we used different ports, but that is not an option for websites. Again we create an VEx with an internal IP-address. On this server we install Lighttpd as well, because the proxying is very simple. If someone has an working example with Apache, please add. First we must forward port 80 to this server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP -d &amp;amp;lt;external IP-address&amp;gt; --dport 80 $dnat 192.168.13.11:80&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we create for every website an section in /etc/lighttpd/lighttpd.conf as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$HTTP[&amp;quot;host&amp;quot;] == &amp;quot;ve101.armorica.tk&amp;quot; {&lt;br /&gt;
  proxy.server  = ( &amp;quot;&amp;quot; =&amp;gt; ( ( &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;192.168.13.101&amp;quot; ) ) )&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can map more names to the same IP-address if needed. The last step is to add mod_proxy to the server.modules section.&lt;br /&gt;
&lt;br /&gt;
=== Other applications ===&lt;br /&gt;
&lt;br /&gt;
Create for other applications as mail, make sure that the minimal servers use this one for sending mail from webpages, DNS etc. VEx as needed. The resulting sever looks something lik this:&lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1944</id>
		<title>Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1944"/>
		<updated>2006-08-03T09:29:53Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* The solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== The problem ==&lt;br /&gt;
&lt;br /&gt;
'''Note: this is my first try to create an Wiki article. Please modify :-)'''&lt;br /&gt;
&lt;br /&gt;
One of the problems with shared webhosting (i.e. different people with each his/her own webpages) is that modern script languages such as PHP, Python or Perl are to powerfull. For example take the following PHP script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function get_content($filename) {&lt;br /&gt;
  $handle = fopen($filename, 'r');&lt;br /&gt;
  echo fread($handle, filesize($filename));&lt;br /&gt;
  fclose($handle);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
get_content('/home/ppuk34/www/forum/config.inc.php');&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With PHP you could use open_basedir to prevent this, but there are more ways. For example [http://mgeisler.net/php-shell/ PHP Shell], a script that is [http://mgeisler.net/downloads/phpshell/SECURITY often mis-used] by people with not-so-good intentions. Or think about the [http://www.f-secure.com/v-descs/santy_a.shtml Santy-worm] which mis-used phpBB. Again there is a solution in the form of safe_mode, but lots of PHP scripts break if you enable this. For Python, Perl or CGI-scripts there are no easy ways and you have to use wrappers or other tricks to chroot these. Most users don't want to hear about security (unless you show them how easy it is) and just want there scripts to work. Some do care, but his/her own server is much to expensive. And finally we didn't talk about hidden bugs in almost every security measure we mentioned. A knowledgeable person can almost certain find backdoors because of the vast amount of possibilities these scripting languages offer.&lt;br /&gt;
&lt;br /&gt;
== The solution ==&lt;br /&gt;
&lt;br /&gt;
[[Image:Shared hosting1.png|300px|right|The OpenVZ way of shared webhosting]]&lt;br /&gt;
&lt;br /&gt;
As said, you can waste hours of time in securing all the possible things you don't want in your shared webhosting environment. And unless you are very familiar with all the things modern scripting languages can do, you pronbably miss dozens of alternative routes. In this process you frustrate your clients, because security always means that legitimate things break. As a side effect of your hard work, you can waste hours of extra time in educating your users. But in the end most users don't care about security, unless they are themselve victims of a comprimised host. Learning the hard way is by far the most effective method.&lt;br /&gt;
&lt;br /&gt;
Instead of the above route, we take a different approach. The main problem is that by its very nature all files which are served through the web are public. Apache for example uses only one account to read alle files. As said, you can use tricks with CGI wrappers to execute the scripting languages under its own credentials. However this kind of security depends on the wrappers ability to securely seperate the users. We all know that if this is broken &amp;amp;mdash; and most often it will be broken &amp;amp;mdash; the result is a higher clearance on the underlying filesystem. For most systems you need more than one wrapper, so the number of possible security problems grow. The ultimate user separation is in the kernel and you can view the modifications OpenVZ has done in this light. Instead of CGI wrappers we go one step higher and give every user its own minimal server. In the rest of this article we describe how shared webhosting with OpenVZ could be implemented.&lt;br /&gt;
&lt;br /&gt;
=== Minimal server ===&lt;br /&gt;
&lt;br /&gt;
Create an VEx with your favorite distro. Give it an internal IP-address in one of the ranges 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Then strip away all unessary init.d scripts so only the bare minimum is started. That means as a minimum syslogd and ssh so the account holder can upload his/her files through SCP/SFTP in his/her own minimal server. For this to work you need to set up [[Using NAT for VE with private IPs|destination NAT on VE0]] from high numbered ports to port 22 on the given private IP address:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The other thing you want for webhosting is of course a webserver as well. To minimize the amount of needed memory, we choose [http://www.lighttpd.net/ Lighttpd] instead of the common Apache. Then configure the scripting language of your choice to run under this webserver. It is possible to use different languages/setups for different accounts as well. Also problematic CGI-scripts are not problematic anymore...&lt;br /&gt;
&lt;br /&gt;
=== MySQL server ===&lt;br /&gt;
&lt;br /&gt;
Most webhosting accounts use MySQL, but if you prefer another database server, go ahead. Create a new VEx with a lot more resources and again an internal IP-address. Now configure the accounts. As an extra security measure you can use the internal IP-address as well.&lt;br /&gt;
&lt;br /&gt;
=== Proxy webserver ===&lt;br /&gt;
&lt;br /&gt;
Because we have only one public IP-address, we need an trick to access every minimal server based on the hostname in the HTTP request. For SSH we used different ports, but that is not an option for websites. Again we create an VEx with an internal IP-address. On this server we install Lighttpd as well, because the proxying is very simple. If someone has an working example with Apache, please add. First we must forward port 80 to this server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP -d &amp;amp;lt;external IP-address&amp;gt; --dport 80 $dnat 192.168.13.11:80&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we create for every website an section in /etc/lighttpd/lighttpd.conf as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$HTTP[&amp;quot;host&amp;quot;] == &amp;quot;ve101.armorica.tk&amp;quot; {&lt;br /&gt;
  proxy.server  = ( &amp;quot;&amp;quot; =&amp;gt; ( ( &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;192.168.13.101&amp;quot; ) ) )&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can map more names to the same IP-address if needed. The last step is to add mod_proxy to the server.modules section.&lt;br /&gt;
&lt;br /&gt;
=== Other applications ===&lt;br /&gt;
&lt;br /&gt;
Create for other applications as mail, make sure that the minimal servers use this one for sending mail from webpages, DNS etc. VEx as needed. The resulting sever looks something lik this:&lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1943</id>
		<title>Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1943"/>
		<updated>2006-08-03T09:26:09Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* The solution */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== The problem ==&lt;br /&gt;
&lt;br /&gt;
'''Note: this is my first try to create an Wiki article. Please modify :-)'''&lt;br /&gt;
&lt;br /&gt;
One of the problems with shared webhosting (i.e. different people with each his/her own webpages) is that modern script languages such as PHP, Python or Perl are to powerfull. For example take the following PHP script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function get_content($filename) {&lt;br /&gt;
  $handle = fopen($filename, 'r');&lt;br /&gt;
  echo fread($handle, filesize($filename));&lt;br /&gt;
  fclose($handle);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
get_content('/home/ppuk34/www/forum/config.inc.php');&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With PHP you could use open_basedir to prevent this, but there are more ways. For example [http://mgeisler.net/php-shell/ PHP Shell], a script that is [http://mgeisler.net/downloads/phpshell/SECURITY often mis-used] by people with not-so-good intentions. Or think about the [http://www.f-secure.com/v-descs/santy_a.shtml Santy-worm] which mis-used phpBB. Again there is a solution in the form of safe_mode, but lots of PHP scripts break if you enable this. For Python, Perl or CGI-scripts there are no easy ways and you have to use wrappers or other tricks to chroot these. Most users don't want to hear about security (unless you show them how easy it is) and just want there scripts to work. Some do care, but his/her own server is much to expensive. And finally we didn't talk about hidden bugs in almost every security measure we mentioned. A knowledgeable person can almost certain find backdoors because of the vast amount of possibilities these scripting languages offer.&lt;br /&gt;
&lt;br /&gt;
== The solution ==&lt;br /&gt;
&lt;br /&gt;
As said, you can waste hours of time in securing all the possible things you don't want in your shared webhosting environment. And unless you are very familiar with all the things modern scripting languages can do, you pronbably miss dozens of alternative routes. In this process you frustrate your clients, because security always means that legitimate things break. As a side effect of your hard work, you can waste hours of extra time in educating your users. But in the end most users don't care about security, unless they are themselve victims of a comprimised host. Learning the hard way is by far the most effective method.&lt;br /&gt;
&lt;br /&gt;
Instead of the above route, we take a different approach. The main problem is that by its very nature all files which are served through the web are public. Apache for example uses only one account to read alle files. As said, you can use tricks with CGI wrappers to execute the scripting languages under its own credentials. However this kind of security depends on the wrappers ability to securely seperate the users. We all know that if this is broken &amp;amp;mdash; and most often it will be broken &amp;amp;mdash; the result is a higher clearance on the underlying filesystem. For most systems you need more than one wrapper, so the number of possible security problems grow. The ultimate user separation is in the kernel and you can view the modifications OpenVZ has done in this light. Instead of CGI wrappers we go one step higher and give every user its own minimal server. In the rest of this article we describe how shared webhosting with OpenVZ could be implemented.&lt;br /&gt;
&lt;br /&gt;
=== Minimal server ===&lt;br /&gt;
&lt;br /&gt;
Create an VEx with your favorite distro. Give it an internal IP-address in one of the ranges 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Then strip away all unessary init.d scripts so only the bare minimum is started. That means as a minimum syslogd and ssh so the account holder can upload his/her files through SCP/SFTP in his/her own minimal server. For this to work you need to set up [[Using NAT for VE with private IPs|destination NAT on VE0]] from high numbered ports to port 22 on the given private IP address:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The other thing you want for webhosting is of course a webserver as well. To minimize the amount of needed memory, we choose [http://www.lighttpd.net/ Lighttpd] instead of the common Apache. Then configure the scripting language of your choice to run under this webserver. It is possible to use different languages/setups for different accounts as well. Also problematic CGI-scripts are not problematic anymore...&lt;br /&gt;
&lt;br /&gt;
=== MySQL server ===&lt;br /&gt;
&lt;br /&gt;
Most webhosting accounts use MySQL, but if you prefer another database server, go ahead. Create a new VEx with a lot more resources and again an internal IP-address. Now configure the accounts. As an extra security measure you can use the internal IP-address as well.&lt;br /&gt;
&lt;br /&gt;
=== Proxy webserver ===&lt;br /&gt;
&lt;br /&gt;
Because we have only one public IP-address, we need an trick to access every minimal server based on the hostname in the HTTP request. For SSH we used different ports, but that is not an option for websites. Again we create an VEx with an internal IP-address. On this server we install Lighttpd as well, because the proxying is very simple. If someone has an working example with Apache, please add. First we must forward port 80 to this server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP -d &amp;amp;lt;external IP-address&amp;gt; --dport 80 $dnat 192.168.13.11:80&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we create for every website an section in /etc/lighttpd/lighttpd.conf as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$HTTP[&amp;quot;host&amp;quot;] == &amp;quot;ve101.armorica.tk&amp;quot; {&lt;br /&gt;
  proxy.server  = ( &amp;quot;&amp;quot; =&amp;gt; ( ( &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;192.168.13.101&amp;quot; ) ) )&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can map more names to the same IP-address if needed. The last step is to add mod_proxy to the server.modules section.&lt;br /&gt;
&lt;br /&gt;
=== Other applications ===&lt;br /&gt;
&lt;br /&gt;
Create for other applications as mail, make sure that the minimal servers use this one for sending mail from webpages, DNS etc. VEx as needed. The resulting sever looks something lik this:&lt;br /&gt;
&lt;br /&gt;
[[Image:Shared hosting1.png]]&lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Talk:Shared_webhosting&amp;diff=1942</id>
		<title>Talk:Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Talk:Shared_webhosting&amp;diff=1942"/>
		<updated>2006-08-02T15:42:47Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* Rename? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;--[[User:Hvdkamer|Hvdkamer]] 08:23, 2 August 2006 (EDT)&lt;br /&gt;
I probably did something stupid, but how can I link from the HOWTO's to this page?&lt;br /&gt;
: If you want to link to the Category:HOWTO, you put it like this&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[:Category:HOWTO HOWTOs (i.e. this is link text)]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
: If you want your article to be included into HOWTO category, you put it like this (in any part of the article, usually at the end):&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[Category:HOWTO]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
: --[[User:Kir|Kir]] 09:51, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
== Rename? ==&lt;br /&gt;
&lt;br /&gt;
I suggest renaming the article to something like &amp;quot;Application separation&amp;quot; or &amp;quot;Services separation&amp;quot; since this is what you actually describe :) --[[User:Kir|Kir]] 10:22, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
Go ahead if you think it describes the content better. I started to investigate OpenVZ because I had serious problems with shared hosting. The minimal servers (it is only a rough draft at this moment) are the solution to that. You could see this as application seperation, but for the end-user it is a &amp;quot;normal&amp;quot; webhosting account. Only he/she can do much more and can not break his/her prison :-)&lt;br /&gt;
--[[User:Hvdkamer|Hvdkamer]] 10:28, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
May be to explain better my choice. After some serious problems with PHP (users who knew where an include with passwords lived, could see the content) I started to investigate the option of Apache threads with its own user credentials. That was the abonded project perchild. So there is not an easy technical solution. Also users hate safe_mode and open_basedir because it breaks there applications. They also want obscure CGI-scripts and all the things we administrators hate. I already used chrooted OpenSSH shell accounts. With the minimal servers I take that one step further. Now every user has total control (he/she can even be root) over his/her space.&lt;br /&gt;
&lt;br /&gt;
If I had to do my research again, I think I would still start with &amp;quot;shared webhosting&amp;quot;. Not &amp;quot;application seperation&amp;quot;. I think that my term, although not exactly correct, will draw more people to this site. I think of it as &amp;quot;user seperation&amp;quot;, but that is the whole point of OpenVZ? As said, its your Wiki, so change it if you think it is better :-)&lt;br /&gt;
--[[User:Hvdkamer|Hvdkamer]] 10:40, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
I changed the introduction to give some examples of the problems shared webhosting is facing. I think that you now could see were it is going? I'm still in the process of setting up this server. So I thought to start this page while I'm working on it. Because if you do it weeks later, most subtle points are lost :-)&lt;br /&gt;
--[[User:Hvdkamer|Hvdkamer]] 11:42, 2 August 2006 (EDT)&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Talk:Shared_webhosting&amp;diff=1941</id>
		<title>Talk:Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Talk:Shared_webhosting&amp;diff=1941"/>
		<updated>2006-08-02T15:42:28Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;--[[User:Hvdkamer|Hvdkamer]] 08:23, 2 August 2006 (EDT)&lt;br /&gt;
I probably did something stupid, but how can I link from the HOWTO's to this page?&lt;br /&gt;
: If you want to link to the Category:HOWTO, you put it like this&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[:Category:HOWTO HOWTOs (i.e. this is link text)]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
: If you want your article to be included into HOWTO category, you put it like this (in any part of the article, usually at the end):&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[Category:HOWTO]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
: --[[User:Kir|Kir]] 09:51, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
== Rename? ==&lt;br /&gt;
&lt;br /&gt;
I suggest renaming the article to something like &amp;quot;Application separation&amp;quot; or &amp;quot;Services separation&amp;quot; since this is what you actually describe :) --[[User:Kir|Kir]] 10:22, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
Go ahead if you think it describes the content better. I started to investigate OpenVZ because I had serious problems with shared hosting. The minimal servers (it is only a rough draft at this moment) are the solution to that. You could see this as application seperation, but for the end-user it is a &amp;quot;normal&amp;quot; webhosting account. Only he/she can do much more and can not break his/her prison :-)&lt;br /&gt;
--[[User:Hvdkamer|Hvdkamer]] 10:28, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
May be to explain better my choice. After some serious problems with PHP (users who knew where an include with passwords lived, could see the content) I started to investigate the option of Apache threads with its own user credentials. That was the abonded project perchild. So there is not an easy technical solution. Also users hate safe_mode and open_basedir because it breaks there applications. They also want obscure CGI-scripts and all the things we administrators hate. I already used chrooted OpenSSH shell accounts. With the minimal servers I take that one step further. Now every user has total control (he/she can even be root) over his/her space.&lt;br /&gt;
&lt;br /&gt;
If I had to do my research again, I think I would still start with &amp;quot;shared webhosting&amp;quot;. Not &amp;quot;application seperation&amp;quot;. I think that my term, although not exactly correct, will draw more people to this site. I think of it as &amp;quot;user seperation&amp;quot;, but that is the whole point of OpenVZ? As said, its your Wiki, so change it if you think it is better :-)&lt;br /&gt;
--[[User:Hvdkamer|Hvdkamer]] 10:40, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
I changed the introduction to give some examples of the problems shared webhosting is facing. I think that you now could see were it is going? I'm still in the process of setting up this server. So I thought to start this page while I'm working on it. Because if you do it weeks later, most subtle points are lost :-)&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1940</id>
		<title>Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1940"/>
		<updated>2006-08-02T15:37:10Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* The problem */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== The problem ==&lt;br /&gt;
&lt;br /&gt;
'''Note: this is my first try to create an Wiki article. Please modify :-)'''&lt;br /&gt;
&lt;br /&gt;
One of the problems with shared webhosting (i.e. different people with each his/her own webpages) is that modern script languages such as PHP, Python or Perl are to powerfull. For example take the following PHP script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function get_content($filename) {&lt;br /&gt;
  $handle = fopen($filename, 'r');&lt;br /&gt;
  echo fread($handle, filesize($filename));&lt;br /&gt;
  fclose($handle);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
get_content('/home/ppuk34/www/forum/config.inc.php');&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With PHP you could use open_basedir to prevent this, but there are more ways. For example [http://mgeisler.net/php-shell/ PHP Shell], a script that is [http://mgeisler.net/downloads/phpshell/SECURITY often mis-used] by people with not-so-good intentions. Or think about the [http://www.f-secure.com/v-descs/santy_a.shtml Santy-worm] which mis-used phpBB. Again there is a solution in the form of safe_mode, but lots of PHP scripts break if you enable this. For Python, Perl or CGI-scripts there are no easy ways and you have to use wrappers or other tricks to chroot these. Most users don't want to hear about security (unless you show them how easy it is) and just want there scripts to work. Some do care, but his/her own server is much to expensive. And finally we didn't talk about hidden bugs in almost every security measure we mentioned. A knowledgeable person can almost certain find backdoors because of the vast amount of possibilities these scripting languages offer.&lt;br /&gt;
&lt;br /&gt;
== The solution ==&lt;br /&gt;
&lt;br /&gt;
Instead of wasting time to secure all the possible things you don't want as a webhoster and in the process frustrate your clients, it is far better, easier and more flexible to give every account its own environment. OpenVZ is ideal for this. In this article we describe how shared webhosting with OpenVZ could be implemented.&lt;br /&gt;
&lt;br /&gt;
=== Minimal server ===&lt;br /&gt;
&lt;br /&gt;
Create an VEx with your favorite distro. Give it an internal IP-address in one of the ranges 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Then strip away all unessary init.d scripts so only the bare minimum is started. That means as a minimum syslogd and ssh so the account holder can upload his/her files through SCP/SFTP in his/her own minimal server. For this to work you need to set up [[Using NAT for VE with private IPs|destination NAT on VE0]] from high numbered ports to port 22 on the given private IP address:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The other thing you want for webhosting is of course a webserver as well. To minimize the amount of needed memory, we choose [http://www.lighttpd.net/ Lighttpd] instead of the common Apache. Then configure the scripting language of your choice to run under this webserver. It is possible to use different languages/setups for different accounts as well. Also problematic CGI-scripts are not problematic anymore...&lt;br /&gt;
&lt;br /&gt;
=== MySQL server ===&lt;br /&gt;
&lt;br /&gt;
Most webhosting accounts use MySQL, but if you prefer another database server, go ahead. Create a new VEx with a lot more resources and again an internal IP-address. Now configure the accounts. As an extra security measure you can use the internal IP-address as well.&lt;br /&gt;
&lt;br /&gt;
=== Proxy webserver ===&lt;br /&gt;
&lt;br /&gt;
Because we have only one public IP-address, we need an trick to access every minimal server based on the hostname in the HTTP request. For SSH we used different ports, but that is not an option for websites. Again we create an VEx with an internal IP-address. On this server we install Lighttpd as well, because the proxying is very simple. If someone has an working example with Apache, please add. First we must forward port 80 to this server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP -d &amp;amp;lt;external IP-address&amp;gt; --dport 80 $dnat 192.168.13.11:80&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we create for every website an section in /etc/lighttpd/lighttpd.conf as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$HTTP[&amp;quot;host&amp;quot;] == &amp;quot;ve101.armorica.tk&amp;quot; {&lt;br /&gt;
  proxy.server  = ( &amp;quot;&amp;quot; =&amp;gt; ( ( &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;192.168.13.101&amp;quot; ) ) )&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can map more names to the same IP-address if needed. The last step is to add mod_proxy to the server.modules section.&lt;br /&gt;
&lt;br /&gt;
=== Other applications ===&lt;br /&gt;
&lt;br /&gt;
Create for other applications as mail, make sure that the minimal servers use this one for sending mail from webpages, DNS etc. VEx as needed. The resulting sever looks something lik this:&lt;br /&gt;
&lt;br /&gt;
[[Image:Shared hosting1.png]]&lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1939</id>
		<title>Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1939"/>
		<updated>2006-08-02T15:36:10Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* The problem */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== The problem ==&lt;br /&gt;
&lt;br /&gt;
'''Note: this is my first try to create an Wiki article. Please modify :-)'''&lt;br /&gt;
&lt;br /&gt;
One of the problems with shared webhosting (i.e. different people with each his/her own webpages) is that modern script languages such as PHP, Python or Perl are to powerfull. For example take the following PHP script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function get_content($filename) {&lt;br /&gt;
  $handle = fopen($filename, 'r');&lt;br /&gt;
  echo fread($handle, filesize($filename));&lt;br /&gt;
  fclose($handle);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
get_content('/home/ppuk34/www/forum/config.inc.php');&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With PHP you could use open_basedir to prevent this, but there are more ways. Another example is [http://mgeisler.net/php-shell/ PHP Shell], a script that is [http://mgeisler.net/downloads/phpshell/SECURITY often mis-used] by people with not-so-good intentions. Or think about the [http://www.f-secure.com/v-descs/santy_a.shtml Santy-worm] which mis-used phpBB. Again there is a solution in the form of safe_mode, but lots of PHP scripts break if you enable this. For Python, Perl or CGI-scripts there are no easy ways and you have to use wrappers or other tricks to chroot these. Most users don't want to hear about security (unless you show them how easy it is) and just want there scripts to work. Some do care, but his/her own server is much to expensive. And finally we didn't talk about hidden bugs in almost every security measure we mentioned. A knowledgeable person can almost certain find backdoors because of the vast amount of possibilities these scripting languages offer.&lt;br /&gt;
&lt;br /&gt;
== The solution ==&lt;br /&gt;
&lt;br /&gt;
Instead of wasting time to secure all the possible things you don't want as a webhoster and in the process frustrate your clients, it is far better, easier and more flexible to give every account its own environment. OpenVZ is ideal for this. In this article we describe how shared webhosting with OpenVZ could be implemented.&lt;br /&gt;
&lt;br /&gt;
=== Minimal server ===&lt;br /&gt;
&lt;br /&gt;
Create an VEx with your favorite distro. Give it an internal IP-address in one of the ranges 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Then strip away all unessary init.d scripts so only the bare minimum is started. That means as a minimum syslogd and ssh so the account holder can upload his/her files through SCP/SFTP in his/her own minimal server. For this to work you need to set up [[Using NAT for VE with private IPs|destination NAT on VE0]] from high numbered ports to port 22 on the given private IP address:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The other thing you want for webhosting is of course a webserver as well. To minimize the amount of needed memory, we choose [http://www.lighttpd.net/ Lighttpd] instead of the common Apache. Then configure the scripting language of your choice to run under this webserver. It is possible to use different languages/setups for different accounts as well. Also problematic CGI-scripts are not problematic anymore...&lt;br /&gt;
&lt;br /&gt;
=== MySQL server ===&lt;br /&gt;
&lt;br /&gt;
Most webhosting accounts use MySQL, but if you prefer another database server, go ahead. Create a new VEx with a lot more resources and again an internal IP-address. Now configure the accounts. As an extra security measure you can use the internal IP-address as well.&lt;br /&gt;
&lt;br /&gt;
=== Proxy webserver ===&lt;br /&gt;
&lt;br /&gt;
Because we have only one public IP-address, we need an trick to access every minimal server based on the hostname in the HTTP request. For SSH we used different ports, but that is not an option for websites. Again we create an VEx with an internal IP-address. On this server we install Lighttpd as well, because the proxying is very simple. If someone has an working example with Apache, please add. First we must forward port 80 to this server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP -d &amp;amp;lt;external IP-address&amp;gt; --dport 80 $dnat 192.168.13.11:80&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we create for every website an section in /etc/lighttpd/lighttpd.conf as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$HTTP[&amp;quot;host&amp;quot;] == &amp;quot;ve101.armorica.tk&amp;quot; {&lt;br /&gt;
  proxy.server  = ( &amp;quot;&amp;quot; =&amp;gt; ( ( &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;192.168.13.101&amp;quot; ) ) )&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can map more names to the same IP-address if needed. The last step is to add mod_proxy to the server.modules section.&lt;br /&gt;
&lt;br /&gt;
=== Other applications ===&lt;br /&gt;
&lt;br /&gt;
Create for other applications as mail, make sure that the minimal servers use this one for sending mail from webpages, DNS etc. VEx as needed. The resulting sever looks something lik this:&lt;br /&gt;
&lt;br /&gt;
[[Image:Shared hosting1.png]]&lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1938</id>
		<title>Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1938"/>
		<updated>2006-08-02T15:20:32Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== The problem ==&lt;br /&gt;
&lt;br /&gt;
'''Note: this is my first try to create an Wiki article. Please modify :-)'''&lt;br /&gt;
&lt;br /&gt;
One of the problems with shared webhosting (i.e. different people with each his/her own webpages) is that modern script languages as PHP, Python or Perl are to powerfull. They can read almost every file on the system. For example take the following PHP script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function get_content($filename) {&lt;br /&gt;
  $handle = fopen($filename, 'r');&lt;br /&gt;
  echo fread($handle, filesize($filename));&lt;br /&gt;
  fclose($handle);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
get_content('/home/ppuk34/www/forum/config.inc.php');&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With PHP you could use open_basedir to prevent this, but there are more ways. And with Python, Perl or CGI-scripts there is no easy way. Plus that users don't care if it is about security (unless you show them how easy it is), so there is a big dillema. And we didn't even talk about hidden bugs in almost every security measure we take. A knowledgeable person can almost certain find backdoors because of the vast amount of possibilities these scripting languages offer.&lt;br /&gt;
&lt;br /&gt;
== The solution ==&lt;br /&gt;
&lt;br /&gt;
Instead of wasting time to secure all the possible things you don't want as a webhoster and in the process frustrate your clients, it is far better, easier and more flexible to give every account its own environment. OpenVZ is ideal for this. In this article we describe how shared webhosting with OpenVZ could be implemented.&lt;br /&gt;
&lt;br /&gt;
=== Minimal server ===&lt;br /&gt;
&lt;br /&gt;
Create an VEx with your favorite distro. Give it an internal IP-address in one of the ranges 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Then strip away all unessary init.d scripts so only the bare minimum is started. That means as a minimum syslogd and ssh so the account holder can upload his/her files through SCP/SFTP in his/her own minimal server. For this to work you need to set up [[Using NAT for VE with private IPs|destination NAT on VE0]] from high numbered ports to port 22 on the given private IP address:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The other thing you want for webhosting is of course a webserver as well. To minimize the amount of needed memory, we choose [http://www.lighttpd.net/ Lighttpd] instead of the common Apache. Then configure the scripting language of your choice to run under this webserver. It is possible to use different languages/setups for different accounts as well. Also problematic CGI-scripts are not problematic anymore...&lt;br /&gt;
&lt;br /&gt;
=== MySQL server ===&lt;br /&gt;
&lt;br /&gt;
Most webhosting accounts use MySQL, but if you prefer another database server, go ahead. Create a new VEx with a lot more resources and again an internal IP-address. Now configure the accounts. As an extra security measure you can use the internal IP-address as well.&lt;br /&gt;
&lt;br /&gt;
=== Proxy webserver ===&lt;br /&gt;
&lt;br /&gt;
Because we have only one public IP-address, we need an trick to access every minimal server based on the hostname in the HTTP request. For SSH we used different ports, but that is not an option for websites. Again we create an VEx with an internal IP-address. On this server we install Lighttpd as well, because the proxying is very simple. If someone has an working example with Apache, please add. First we must forward port 80 to this server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP -d &amp;amp;lt;external IP-address&amp;gt; --dport 80 $dnat 192.168.13.11:80&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we create for every website an section in /etc/lighttpd/lighttpd.conf as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$HTTP[&amp;quot;host&amp;quot;] == &amp;quot;ve101.armorica.tk&amp;quot; {&lt;br /&gt;
  proxy.server  = ( &amp;quot;&amp;quot; =&amp;gt; ( ( &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;192.168.13.101&amp;quot; ) ) )&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can map more names to the same IP-address if needed. The last step is to add mod_proxy to the server.modules section.&lt;br /&gt;
&lt;br /&gt;
=== Other applications ===&lt;br /&gt;
&lt;br /&gt;
Create for other applications as mail, make sure that the minimal servers use this one for sending mail from webpages, DNS etc. VEx as needed. The resulting sever looks something lik this:&lt;br /&gt;
&lt;br /&gt;
[[Image:Shared hosting1.png]]&lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1937</id>
		<title>Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1937"/>
		<updated>2006-08-02T15:19:04Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* Shared webhosting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== The problem ==&lt;br /&gt;
&lt;br /&gt;
'''Note: this is my first try to create an Wiki article. Please modify :-)'''&lt;br /&gt;
&lt;br /&gt;
One of the problems with shared webhosting (i.e. different people with each his/her own webpages) is that modern script languages as PHP, Python or Perl are to powerfull. They can read almost every file on the system. For example take the following PHP script:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
&lt;br /&gt;
function get_content($filename) {&lt;br /&gt;
  $handle = fopen($filename, 'r');&lt;br /&gt;
  echo fread($handle, filesize($filename));&lt;br /&gt;
  fclose($handle);&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
get_content('/home/ppuk34/www/forum/config.inc.php');&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
With PHP you could use open_basedir to prevent this, but there are more ways. And with Python, Perl or CGI-scripts there is no easy way. Plus that users don't care if it is about security (unless you show them how easy it is), so there is a big dillema. And we didn't even talk about hidden bugs in almost every security measure we take. A knowledgeable person can almost certain find backdoors because of the vast amount of possibilities these scripting languages offer. Instead of wasting time to secure all the possible things you don't want as a webhoster and in the process frustrate your clients, it is far better, easier and more flexible to give every account its own environment. OpenVZ is ideal for this. In this article we describe how shared webhosting with OpenVZ could be implemented.&lt;br /&gt;
&lt;br /&gt;
=== Minimal server ===&lt;br /&gt;
&lt;br /&gt;
Create an VEx with your favorite distro. Give it an internal IP-address in one of the ranges 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Then strip away all unessary init.d scripts so only the bare minimum is started. That means as a minimum syslogd and ssh so the account holder can upload his/her files through SCP/SFTP in his/her own minimal server. For this to work you need to set up [[Using NAT for VE with private IPs|destination NAT on VE0]] from high numbered ports to port 22 on the given private IP address:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The other thing you want for webhosting is of course a webserver as well. To minimize the amount of needed memory, we choose [http://www.lighttpd.net/ Lighttpd] instead of the common Apache. Then configure the scripting language of your choice to run under this webserver. It is possible to use different languages/setups for different accounts as well. Also problematic CGI-scripts are not problematic anymore...&lt;br /&gt;
&lt;br /&gt;
=== MySQL server ===&lt;br /&gt;
&lt;br /&gt;
Most webhosting accounts use MySQL, but if you prefer another database server, go ahead. Create a new VEx with a lot more resources and again an internal IP-address. Now configure the accounts. As an extra security measure you can use the internal IP-address as well.&lt;br /&gt;
&lt;br /&gt;
=== Proxy webserver ===&lt;br /&gt;
&lt;br /&gt;
Because we have only one public IP-address, we need an trick to access every minimal server based on the hostname in the HTTP request. For SSH we used different ports, but that is not an option for websites. Again we create an VEx with an internal IP-address. On this server we install Lighttpd as well, because the proxying is very simple. If someone has an working example with Apache, please add. First we must forward port 80 to this server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP -d &amp;amp;lt;external IP-address&amp;gt; --dport 80 $dnat 192.168.13.11:80&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we create for every website an section in /etc/lighttpd/lighttpd.conf as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$HTTP[&amp;quot;host&amp;quot;] == &amp;quot;ve101.armorica.tk&amp;quot; {&lt;br /&gt;
  proxy.server  = ( &amp;quot;&amp;quot; =&amp;gt; ( ( &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;192.168.13.101&amp;quot; ) ) )&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can map more names to the same IP-address if needed. The last step is to add mod_proxy to the server.modules section.&lt;br /&gt;
&lt;br /&gt;
=== Other applications ===&lt;br /&gt;
&lt;br /&gt;
Create for other applications as mail, make sure that the minimal servers use this one for sending mail from webpages, DNS etc. VEx as needed. The resulting sever looks something lik this:&lt;br /&gt;
&lt;br /&gt;
[[Image:Shared hosting1.png]]&lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Talk:Shared_webhosting&amp;diff=1936</id>
		<title>Talk:Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Talk:Shared_webhosting&amp;diff=1936"/>
		<updated>2006-08-02T15:02:59Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* Rename? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;--[[User:Hvdkamer|Hvdkamer]] 08:23, 2 August 2006 (EDT)&lt;br /&gt;
I probably did something stupid, but how can I link from the HOWTO's to this page?&lt;br /&gt;
: If you want to link to the Category:HOWTO, you put it like this&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[:Category:HOWTO HOWTOs (i.e. this is link text)]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
: If you want your article to be included into HOWTO category, you put it like this (in any part of the article, usually at the end):&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[Category:HOWTO]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
: --[[User:Kir|Kir]] 09:51, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
== Rename? ==&lt;br /&gt;
&lt;br /&gt;
I suggest renaming the article to something like &amp;quot;Application separation&amp;quot; or &amp;quot;Services separation&amp;quot; since this is what you actually describe :) --[[User:Kir|Kir]] 10:22, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
Go ahead if you think it describes the content better. I started to investigate OpenVZ because I had serious problems with shared hosting. The minimal servers (it is only a rough draft at this moment) are the solution to that. You could see this as application seperation, but for the end-user it is a &amp;quot;normal&amp;quot; webhosting account. Only he/she can do much more and can not break his/her prison :-)&lt;br /&gt;
--[[User:Hvdkamer|Hvdkamer]] 10:28, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
May be to explain better my choice. After some serious problems with PHP (users who knew where an include with passwords lived, could see the content) I started to investigate the option of Apache threads with its own user credentials. That was the abonded project perchild. So there is not an easy technical solution. Also users hate safe_mode and open_basedir because it breaks there applications. They also want obscure CGI-scripts and all the things we administrators hate. I already used chrooted OpenSSH shell accounts. With the minimal servers I take that one step further. Now every user has total control (he/she can even be root) over his/her space.&lt;br /&gt;
&lt;br /&gt;
If I had to do my research again, I think I would still start with &amp;quot;shared webhosting&amp;quot;. Not &amp;quot;application seperation&amp;quot;. I think that my term, although not exactly correct, will draw more people to this site. I think of it as &amp;quot;user seperation&amp;quot;, but that is the whole point of OpenVZ? As said, its your Wiki, so change it if you think it is better :-)&lt;br /&gt;
--[[User:Hvdkamer|Hvdkamer]] 10:40, 2 August 2006 (EDT)&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Talk:Shared_webhosting&amp;diff=1935</id>
		<title>Talk:Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Talk:Shared_webhosting&amp;diff=1935"/>
		<updated>2006-08-02T14:40:19Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* Rename? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;--[[User:Hvdkamer|Hvdkamer]] 08:23, 2 August 2006 (EDT)&lt;br /&gt;
I probably did something stupid, but how can I link from the HOWTO's to this page?&lt;br /&gt;
: If you want to link to the Category:HOWTO, you put it like this&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[:Category:HOWTO HOWTOs (i.e. this is link text)]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
: If you want your article to be included into HOWTO category, you put it like this (in any part of the article, usually at the end):&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[Category:HOWTO]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
: --[[User:Kir|Kir]] 09:51, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
== Rename? ==&lt;br /&gt;
&lt;br /&gt;
I suggest renaming the article to something like &amp;quot;Application separation&amp;quot; or &amp;quot;Services separation&amp;quot; since this is what you actually describe :) --[[User:Kir|Kir]] 10:22, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
Go ahead if you think it describes the content better. I started to investigate OpenVZ because I had serious problems with shared hosting. The minimal servers (it is only a rough draft at this moment) are the solution to that. You could see this as application seperation, but for the end-user it is a &amp;quot;normal&amp;quot; webhosting account. Only he/she can do much more and can not break his/her prison :-)&lt;br /&gt;
--[[User:Hvdkamer|Hvdkamer]] 10:28, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
May be to explain better my choice. After some serious problems with PHP (users who knew where an include with passwords lived, could see the content) I started to investigate the option of Apache threads with its own user credentials. That was the abonded project perchild. So there is not an easy technical solution. Also users hate safe_mode and open_basedir because it breaks there applications. They also want obscure CGI-scripts and all the things we administrators hate. I already used chrooted OpenSSH shell accounts. With the minimal servers I take that one step further. Now every user has total control (he/she can even be root) over his/her space.&lt;br /&gt;
&lt;br /&gt;
If I had to do my research again, I still start with &amp;quot;shared webhosting&amp;quot;. Not &amp;quot;application seperation&amp;quot;. I think that my term, although not exactly correct, will drwa more people to this site. Bu as said, if its your Wiki. If you want to change it, go ahead.&lt;br /&gt;
--[[User:Hvdkamer|Hvdkamer]] 10:40, 2 August 2006 (EDT)&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Talk:Shared_webhosting&amp;diff=1934</id>
		<title>Talk:Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Talk:Shared_webhosting&amp;diff=1934"/>
		<updated>2006-08-02T14:39:46Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;--[[User:Hvdkamer|Hvdkamer]] 08:23, 2 August 2006 (EDT)&lt;br /&gt;
I probably did something stupid, but how can I link from the HOWTO's to this page?&lt;br /&gt;
: If you want to link to the Category:HOWTO, you put it like this&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[:Category:HOWTO HOWTOs (i.e. this is link text)]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
: If you want your article to be included into HOWTO category, you put it like this (in any part of the article, usually at the end):&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[Category:HOWTO]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
: --[[User:Kir|Kir]] 09:51, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
== Rename? ==&lt;br /&gt;
&lt;br /&gt;
I suggest renaming the article to something like &amp;quot;Application separation&amp;quot; or &amp;quot;Services separation&amp;quot; since this is what you actually describe :) --[[User:Kir|Kir]] 10:22, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
Go ahead if you think it describes the content better. I started to investigate OpenVZ because I had serious problems with shared hosting. The minimal servers (it is only a rough draft at this moment) are the solution to that. You could see this as application seperation, but for the end-user it is a &amp;quot;normal&amp;quot; webhosting account. Only he/she can do much more and can not break his/her prison :-)&lt;br /&gt;
--[[User:Hvdkamer|Hvdkamer]] 10:28, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
May be to explain better my choice. After some serious problems with PHP (users who knew where an include with passwords lived, could see the content) I started to investigate the option of Apache threads with its own user credentials. That was the abonded project perchild. So there is not an easy technical solution. Also users hate safe_mode and open_basedir because it breaks there applications. They also want obscure CGI-scripts and all the things we administrators hate. I already used chrooted OpenSSH shell accounts. With the minimal servers I take that one step further. Now every user has total control (he/she can even be root) over his/her space.&lt;br /&gt;
&lt;br /&gt;
If I had to do my research again, I still start with &amp;quot;shared webhosting&amp;quot;. Not &amp;quot;application seperation&amp;quot;. I think that my term, although not exactly correct, will drwa more people to this site. Bu as said, if its your Wiki. If you want to change it, go ahead.&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1933</id>
		<title>Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1933"/>
		<updated>2006-08-02T14:29:58Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* Shared webhosting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Shared webhosting ==&lt;br /&gt;
&lt;br /&gt;
'''Note: this is my first try to create an Wiki article. Please modify :-)'''&lt;br /&gt;
&lt;br /&gt;
One of the problems with shared webhosting is that modern script languages as PHP, Python or Perl are to powerfull. They can read almost every file on the system. There are some tricks to prevent some of this, but it is not an easy task. All to often a knowledgeable person can find backdoors because of the vast amount of possibilities these scripting languages offer. The ultimate solution is to lock all the webhosting accounts in there own environment. OpenVZ is ideal for this.&lt;br /&gt;
&lt;br /&gt;
=== Minimal server ===&lt;br /&gt;
&lt;br /&gt;
Create an VEx with your favorite distro. Give it an internal IP-address in one of the ranges 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Then strip away all unessary init.d scripts so only the bare minimum is started. That means as a minimum syslogd and ssh so the account holder can upload his/her files through SCP/SFTP in his/her own minimal server. For this to work you need to set up [[Using NAT for VE with private IPs|destination NAT on VE0]] from high numbered ports to port 22 on the given private IP address:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The other thing you want for webhosting is of course a webserver as well. To minimize the amount of needed memory, we choose [http://www.lighttpd.net/ Lighttpd] instead of the common Apache. Then configure the scripting language of your choice to run under this webserver. It is possible to use different languages/setups for different accounts as well. Also problematic CGI-scripts are not problematic anymore...&lt;br /&gt;
&lt;br /&gt;
=== MySQL server ===&lt;br /&gt;
&lt;br /&gt;
Most webhosting accounts use MySQL, but if you prefer another database server, go ahead. Create a new VEx with a lot more resources and again an internal IP-address. Now configure the accounts. As an extra security measure you can use the internal IP-address as well.&lt;br /&gt;
&lt;br /&gt;
=== Proxy webserver ===&lt;br /&gt;
&lt;br /&gt;
Because we have only one public IP-address, we need an trick to access every minimal server based on the hostname in the HTTP request. For SSH we used different ports, but that is not an option for websites. Again we create an VEx with an internal IP-address. On this server we install Lighttpd as well, because the proxying is very simple. If someone has an working example with Apache, please add. First we must forward port 80 to this server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP -d &amp;amp;lt;external IP-address&amp;gt; --dport 80 $dnat 192.168.13.11:80&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we create for every website an section in /etc/lighttpd/lighttpd.conf as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$HTTP[&amp;quot;host&amp;quot;] == &amp;quot;ve101.armorica.tk&amp;quot; {&lt;br /&gt;
  proxy.server  = ( &amp;quot;&amp;quot; =&amp;gt; ( ( &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;192.168.13.101&amp;quot; ) ) )&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can map more names to the same IP-address if needed. The last step is to add mod_proxy to the server.modules section.&lt;br /&gt;
&lt;br /&gt;
=== Other applications ===&lt;br /&gt;
&lt;br /&gt;
Create for other applications as mail, make sure that the minimal servers use this one for sending mail from webpages, DNS etc. VEx as needed. The resulting sever looks something lik this:&lt;br /&gt;
&lt;br /&gt;
[[Image:Shared hosting1.png]]&lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Talk:Shared_webhosting&amp;diff=1932</id>
		<title>Talk:Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Talk:Shared_webhosting&amp;diff=1932"/>
		<updated>2006-08-02T14:28:45Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* Rename? */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;--[[User:Hvdkamer|Hvdkamer]] 08:23, 2 August 2006 (EDT)&lt;br /&gt;
I probably did something stupid, but how can I link from the HOWTO's to this page?&lt;br /&gt;
: If you want to link to the Category:HOWTO, you put it like this&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[:Category:HOWTO HOWTOs (i.e. this is link text)]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
: If you want your article to be included into HOWTO category, you put it like this (in any part of the article, usually at the end):&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[Category:HOWTO]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
: --[[User:Kir|Kir]] 09:51, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
== Rename? ==&lt;br /&gt;
&lt;br /&gt;
I suggest renaming the article to something like &amp;quot;Application separation&amp;quot; or &amp;quot;Services separation&amp;quot; since this is what you actually describe :) --[[User:Kir|Kir]] 10:22, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
Go ahead if you think it describes the content better. I started to investigate OpenVZ because I had serious problems with shared hosting. The minimal servers (it is only a rough draft at this moment) are the solution to that. You could see this as application seperation, but for the end-user it is a &amp;quot;normal&amp;quot; webhosting account. Only he/she can do much more and can not break his/her prison :-)&lt;br /&gt;
--[[User:Hvdkamer|Hvdkamer]] 10:28, 2 August 2006 (EDT)&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Talk:Shared_webhosting&amp;diff=1931</id>
		<title>Talk:Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Talk:Shared_webhosting&amp;diff=1931"/>
		<updated>2006-08-02T14:28:16Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;--[[User:Hvdkamer|Hvdkamer]] 08:23, 2 August 2006 (EDT)&lt;br /&gt;
I probably did something stupid, but how can I link from the HOWTO's to this page?&lt;br /&gt;
: If you want to link to the Category:HOWTO, you put it like this&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[:Category:HOWTO HOWTOs (i.e. this is link text)]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
: If you want your article to be included into HOWTO category, you put it like this (in any part of the article, usually at the end):&lt;br /&gt;
: &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;[[Category:HOWTO]]&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;&lt;br /&gt;
: --[[User:Kir|Kir]] 09:51, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
== Rename? ==&lt;br /&gt;
&lt;br /&gt;
I suggest renaming the article to something like &amp;quot;Application separation&amp;quot; or &amp;quot;Services separation&amp;quot; since this is what you actually describe :) --[[User:Kir|Kir]] 10:22, 2 August 2006 (EDT)&lt;br /&gt;
&lt;br /&gt;
Go ahead if you think it describes the content better. I started to investigate OpenVZ because I had serious problems with shared hosting. The minimal servers (it is only a rough draft at this moment) are the solution to that. You could see this as application seperation, but for the end-user it is a &amp;quot;normal&amp;quot; webhosting account. Only he/she can do much more and can not break his/her prison :-)&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1928</id>
		<title>Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1928"/>
		<updated>2006-08-02T14:17:13Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* Minimal server */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Shared webhosting ==&lt;br /&gt;
&lt;br /&gt;
'''Note: this is my first try to create an Wiki article. Please modify :-)'''&lt;br /&gt;
&lt;br /&gt;
One of the problems with shared webhosting is that modern script languages as PHP, Python or Perl are to powerful. They can read almost every file on the system. There are some tricks to prevent some of this, but it is not an easy task. All to often a knowledgeable person can find backdoors because of the vast amount of possibilities these scripting languages offer. The ultimate solution is to lock all the webhosting accounts in there own environment. OpenVZ is ideal for this.&lt;br /&gt;
&lt;br /&gt;
=== Minimal server ===&lt;br /&gt;
&lt;br /&gt;
Create an VEx with your favorite distro. Give it an internal IP-address in one of the ranges 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Then strip away all unessary init.d scripts so only the bare minimum is started. That means as a minimum syslogd and ssh so the account holder can upload his/her files through SCP/SFTP in his/her own minimal server. For this to work you need [[http://wiki.openvz.org/Using_NAT_for_VE_with_private_IPs destination NAT on VE0]] from high numbered ports to port 22 on the given private IP-address:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The other thing you want for webhosting is of course a webserver as well. To minimize the amount of needed memory, we choose [http://www.lighttpd.net/ Lighttpd] instead of the common Apache. Then configure the scripting language of your choice to run under this webserver. It is possible to use different languages/setups for different accounts as well. Also problematic CGI-scripts are not problematic anymore...&lt;br /&gt;
&lt;br /&gt;
=== MySQL server ===&lt;br /&gt;
&lt;br /&gt;
Most webhosting accounts use MySQL, but if you prefer another database server, go ahead. Create a new VEx with a lot more resources and again an internal IP-address. Now configure the accounts. As an extra security measure you can use the internal IP-address as well.&lt;br /&gt;
&lt;br /&gt;
=== Proxy webserver ===&lt;br /&gt;
&lt;br /&gt;
Because we have only one public IP-address, we need an trick to access every minimal server based on the hostname in the HTTP request. For SSH we used different ports, but that is not an option for websites. Again we create an VEx with an internal IP-address. On this server we install Lighttpd as well, because the proxying is very simple. If someone has an working example with Apache, please add. First we must forward port 80 to this server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP -d &amp;amp;lt;external IP-address&amp;gt; --dport 80 $dnat 192.168.13.11:80&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we create for every website an section in /etc/lighttpd/lighttpd.conf as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$HTTP[&amp;quot;host&amp;quot;] == &amp;quot;ve101.armorica.tk&amp;quot; {&lt;br /&gt;
  proxy.server  = ( &amp;quot;&amp;quot; =&amp;gt; ( ( &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;192.168.13.101&amp;quot; ) ) )&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can map more names to the same IP-address if needed. The last step is to add mod_proxy to the server.modules section.&lt;br /&gt;
&lt;br /&gt;
=== Other applications ===&lt;br /&gt;
&lt;br /&gt;
Create for other applications as mail, make sure that the minimal servers use this one for sending mail from webpages, DNS etc. VEx as needed. The resulting sever looks something lik this:&lt;br /&gt;
&lt;br /&gt;
[[Image:Shared hosting1.png]]&lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1927</id>
		<title>Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1927"/>
		<updated>2006-08-02T14:12:29Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* Other applications */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Shared webhosting ==&lt;br /&gt;
&lt;br /&gt;
'''Note: this is my first try to create an Wiki article. Please modify :-)'''&lt;br /&gt;
&lt;br /&gt;
One of the problems with shared webhosting is that modern script languages as PHP, Python or Perl are to powerful. They can read almost every file on the system. There are some tricks to prevent some of this, but it is not an easy task. All to often a knowledgeable person can find backdoors because of the vast amount of possibilities these scripting languages offer. The ultimate solution is to lock all the webhosting accounts in there own environment. OpenVZ is ideal for this.&lt;br /&gt;
&lt;br /&gt;
=== Minimal server ===&lt;br /&gt;
&lt;br /&gt;
Create an VEx with your favorite distro. Give it an internal IP-address in one of the ranges 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Then strip away all unessary init.d scripts so only the bare minimum is started. That means as a minimum syslogd and ssh so the account holder can upload his/her files through SCP/SFTP in his/her own minimal server. For this to work you need destination NAT on VE0 from high numbered ports to port 22 on the given private IP-address:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The other thing you want for webhosting is of course a webserver as well. To minimize the amount of needed memory, we choose [http://www.lighttpd.net/ Lighttpd] instead of the common Apache. Then configure the scripting language of your choice to run under this webserver. It is possible to use different languages/setups for different accounts as well. Also problematic CGI-scripts are not problematic anymore...&lt;br /&gt;
&lt;br /&gt;
=== MySQL server ===&lt;br /&gt;
&lt;br /&gt;
Most webhosting accounts use MySQL, but if you prefer another database server, go ahead. Create a new VEx with a lot more resources and again an internal IP-address. Now configure the accounts. As an extra security measure you can use the internal IP-address as well.&lt;br /&gt;
&lt;br /&gt;
=== Proxy webserver ===&lt;br /&gt;
&lt;br /&gt;
Because we have only one public IP-address, we need an trick to access every minimal server based on the hostname in the HTTP request. For SSH we used different ports, but that is not an option for websites. Again we create an VEx with an internal IP-address. On this server we install Lighttpd as well, because the proxying is very simple. If someone has an working example with Apache, please add. First we must forward port 80 to this server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP -d &amp;amp;lt;external IP-address&amp;gt; --dport 80 $dnat 192.168.13.11:80&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we create for every website an section in /etc/lighttpd/lighttpd.conf as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$HTTP[&amp;quot;host&amp;quot;] == &amp;quot;ve101.armorica.tk&amp;quot; {&lt;br /&gt;
  proxy.server  = ( &amp;quot;&amp;quot; =&amp;gt; ( ( &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;192.168.13.101&amp;quot; ) ) )&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can map more names to the same IP-address if needed. The last step is to add mod_proxy to the server.modules section.&lt;br /&gt;
&lt;br /&gt;
=== Other applications ===&lt;br /&gt;
&lt;br /&gt;
Create for other applications as mail, make sure that the minimal servers use this one for sending mail from webpages, DNS etc. VEx as needed. The resulting sever looks something lik this:&lt;br /&gt;
&lt;br /&gt;
[[Image:Shared hosting1.png]]&lt;br /&gt;
&lt;br /&gt;
[[Category:HOWTO]]&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Talk:Shared_webhosting&amp;diff=1924</id>
		<title>Talk:Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Talk:Shared_webhosting&amp;diff=1924"/>
		<updated>2006-08-02T12:23:50Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;--[[User:Hvdkamer|Hvdkamer]] 08:23, 2 August 2006 (EDT)&lt;br /&gt;
I probably did something stupid, but how can I link from the HOWTO's to this page?&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1923</id>
		<title>Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1923"/>
		<updated>2006-08-02T12:21:23Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* Proxy webserver */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Shared webhosting ==&lt;br /&gt;
&lt;br /&gt;
'''Note: this is my first try to create an Wiki article. Please modify :-)'''&lt;br /&gt;
&lt;br /&gt;
One of the problems with shared webhosting is that modern script languages as PHP, Python or Perl are to powerful. They can read almost every file on the system. There are some tricks to prevent some of this, but it is not an easy task. All to often a knowledgeable person can find backdoors because of the vast amount of possibilities these scripting languages offer. The ultimate solution is to lock all the webhosting accounts in there own environment. OpenVZ is ideal for this.&lt;br /&gt;
&lt;br /&gt;
=== Minimal server ===&lt;br /&gt;
&lt;br /&gt;
Create an VEx with your favorite distro. Give it an internal IP-address in one of the ranges 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Then strip away all unessary init.d scripts so only the bare minimum is started. That means as a minimum syslogd and ssh so the account holder can upload his/her files through SCP/SFTP in his/her own minimal server. For this to work you need destination NAT on VE0 from high numbered ports to port 22 on the given private IP-address:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The other thing you want for webhosting is of course a webserver as well. To minimize the amount of needed memory, we choose [http://www.lighttpd.net/ Lighttpd] instead of the common Apache. Then configure the scripting language of your choice to run under this webserver. It is possible to use different languages/setups for different accounts as well. Also problematic CGI-scripts are not problematic anymore...&lt;br /&gt;
&lt;br /&gt;
=== MySQL server ===&lt;br /&gt;
&lt;br /&gt;
Most webhosting accounts use MySQL, but if you prefer another database server, go ahead. Create a new VEx with a lot more resources and again an internal IP-address. Now configure the accounts. As an extra security measure you can use the internal IP-address as well.&lt;br /&gt;
&lt;br /&gt;
=== Proxy webserver ===&lt;br /&gt;
&lt;br /&gt;
Because we have only one public IP-address, we need an trick to access every minimal server based on the hostname in the HTTP request. For SSH we used different ports, but that is not an option for websites. Again we create an VEx with an internal IP-address. On this server we install Lighttpd as well, because the proxying is very simple. If someone has an working example with Apache, please add. First we must forward port 80 to this server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP -d &amp;amp;lt;external IP-address&amp;gt; --dport 80 $dnat 192.168.13.11:80&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we create for every website an section in /etc/lighttpd/lighttpd.conf as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$HTTP[&amp;quot;host&amp;quot;] == &amp;quot;ve101.armorica.tk&amp;quot; {&lt;br /&gt;
  proxy.server  = ( &amp;quot;&amp;quot; =&amp;gt; ( ( &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;192.168.13.101&amp;quot; ) ) )&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can map more names to the same IP-address if needed. The last step is to add mod_proxy to the server.modules section.&lt;br /&gt;
&lt;br /&gt;
=== Other applications ===&lt;br /&gt;
&lt;br /&gt;
Create for other applications as mail, make sure that the minimal servers use this one for sending mail from webpages, DNS etc. VEx as needed. The resulting sever looks something lik this:&lt;br /&gt;
&lt;br /&gt;
[[Image:Shared hosting1.png]]&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1922</id>
		<title>Shared webhosting</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Shared_webhosting&amp;diff=1922"/>
		<updated>2006-08-02T12:17:11Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Shared webhosting ==&lt;br /&gt;
&lt;br /&gt;
'''Note: this is my first try to create an Wiki article. Please modify :-)'''&lt;br /&gt;
&lt;br /&gt;
One of the problems with shared webhosting is that modern script languages as PHP, Python or Perl are to powerful. They can read almost every file on the system. There are some tricks to prevent some of this, but it is not an easy task. All to often a knowledgeable person can find backdoors because of the vast amount of possibilities these scripting languages offer. The ultimate solution is to lock all the webhosting accounts in there own environment. OpenVZ is ideal for this.&lt;br /&gt;
&lt;br /&gt;
=== Minimal server ===&lt;br /&gt;
&lt;br /&gt;
Create an VEx with your favorite distro. Give it an internal IP-address in one of the ranges 10.0.0.0/8, 172.16.0.0/12 or 192.168.0.0/16. Then strip away all unessary init.d scripts so only the bare minimum is started. That means as a minimum syslogd and ssh so the account holder can upload his/her files through SCP/SFTP in his/her own minimal server. For this to work you need destination NAT on VE0 from high numbered ports to port 22 on the given private IP-address:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
The other thing you want for webhosting is of course a webserver as well. To minimize the amount of needed memory, we choose [http://www.lighttpd.net/ Lighttpd] instead of the common Apache. Then configure the scripting language of your choice to run under this webserver. It is possible to use different languages/setups for different accounts as well. Also problematic CGI-scripts are not problematic anymore...&lt;br /&gt;
&lt;br /&gt;
=== MySQL server ===&lt;br /&gt;
&lt;br /&gt;
Most webhosting accounts use MySQL, but if you prefer another database server, go ahead. Create a new VEx with a lot more resources and again an internal IP-address. Now configure the accounts. As an extra security measure you can use the internal IP-address as well.&lt;br /&gt;
&lt;br /&gt;
=== Proxy webserver ===&lt;br /&gt;
&lt;br /&gt;
Because we have only one public IP-address, we need an trick to access every minimal server based on the hostname in the HTTP request. For SSH we used different ports, but that is not an option for websites. Again we create an VEx with an internal IP-address. On this server we install Lighttpd as well, because the proxying is very simple. If someone has an working example with Apache, please add. First we must forward port 80 to this server:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
dnat=&amp;quot;-j DNAT --to-destination&amp;quot;&lt;br /&gt;
&lt;br /&gt;
iptables -t nat -P PREROUTING ACCEPT&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP -d &amp;amp;lt;external IP-address&amp;gt; --dport 80 $dnat 192.168.13.32:80&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10122 $dnat 192.168.13.101:22&lt;br /&gt;
iptables -t nat -A PREROUTING -p TCP --dport 10222 $dnat 192.168.13.102:22&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Then we create for every website an section in /etc/lighttpd/lighttpd.conf as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$HTTP[&amp;quot;host&amp;quot;] == &amp;quot;ve101.armorica.tk&amp;quot; {&lt;br /&gt;
  proxy.server  = ( &amp;quot;&amp;quot; =&amp;gt; ( ( &amp;quot;host&amp;quot; =&amp;gt; &amp;quot;192.168.13.101&amp;quot; ) ) )&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
You can map more names to the same IP-address if needed. The last step is to add mod_proxy to the server.modules section.&lt;br /&gt;
&lt;br /&gt;
=== Other applications ===&lt;br /&gt;
&lt;br /&gt;
Create for other applications as mail, make sure that the minimal servers use this one for sending mail from webpages, DNS etc. VEx as needed. The resulting sever looks something lik this:&lt;br /&gt;
&lt;br /&gt;
[[Image:Shared hosting1.png]]&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=File:Shared_hosting1.png&amp;diff=1921</id>
		<title>File:Shared hosting1.png</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=File:Shared_hosting1.png&amp;diff=1921"/>
		<updated>2006-08-02T12:12:22Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: VE0 is the yellow block, supporting servers are in pink and the minimal servers are in mintgreen.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;VE0 is the yellow block, supporting servers are in pink and the minimal servers are in mintgreen.&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
	<entry>
		<id>https://wiki.openvz.org/index.php?title=Using_NAT_for_container_with_private_IPs&amp;diff=1920</id>
		<title>Using NAT for container with private IPs</title>
		<link rel="alternate" type="text/html" href="https://wiki.openvz.org/index.php?title=Using_NAT_for_container_with_private_IPs&amp;diff=1920"/>
		<updated>2006-08-02T10:56:14Z</updated>

		<summary type="html">&lt;p&gt;Hvdkamer: /* How to provide access for VE to Internet */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== How to provide access for VE to Internet ==&lt;br /&gt;
&lt;br /&gt;
To enable the [[VE]]s, which have only internal IP addresses, to access the Internet, SNAT (Source Network Address Translation, also known as IP masquerading) should be configured on the [[Hardware Node]]. This is ensured by the standard Linux &amp;lt;tt&amp;gt;iptables&amp;lt;/tt&amp;gt; utility. To perform a simple SNAT setup, execute the following command on the [[Hardware Node]]:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# iptables -t nat -A POSTROUTING -s src_net -o eth0 -j SNAT --to ip_address&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;tt&amp;gt;src_net&amp;lt;/tt&amp;gt; is a range of IP addresses of VEs to be translated by SNAT, and &amp;lt;tt&amp;gt;ip_address&amp;lt;/tt&amp;gt; is the external IP address of your [[Hardware Node]]. Multiple rules are allowed, for example, in case you wish to specify several ranges of IP addresses. If you are using a number of physical network interfaces on the [[Hardware Node|Node]], you may need to specify a different interface for outgoing connections, e.g. &amp;lt;tt&amp;gt;-o eth2&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
To make all IP addresses to be translated by SNAT (not only the ones of [[VE]]s with private addresses), you should type the following string:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# iptables -t nat -A POSTROUTING -o eth0 -j SNAT --to ip_address&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Note|If the above is not working then check if one of the following solutions does the trick.}}&lt;br /&gt;
1. If you are using stable (currently 2.6.8-based) kernel, then to enable SNAT for the VEs on your local network you need to explicitly enable connection tracking in [[VE0]]. Make sure that the following string is present in the &amp;lt;tt&amp;gt;/etc/modprobe.conf&amp;lt;/tt&amp;gt; file:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
options ip_conntrack ip_conntrack_enable_ve0=1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
In case it is not, add this string to the file by means of any text editor (for example, vi). This setting is not needed for kernels more recent than 2.6.8, since connection tracking for [[VE0]] is enabled by default in those kernels.&lt;br /&gt;
&lt;br /&gt;
2. For unknown reasons the above didn't work on a Debian host. The solution is to do it in an init.d script as follows:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
modprobe ip_conntrack ip_conntrack_enable_ve0=1&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
Make sure that this module is loaded before any of the other iptables-modules ar loaded! Also remember that if this module is loaded without the option, unloading and reloading doesn't work! You need to reboot the computer.&lt;br /&gt;
&lt;br /&gt;
== How to provide access from Internet to a VE ==&lt;br /&gt;
&lt;br /&gt;
In addition, to make some services in VE with private IP address be accessible from the Internet, DNAT (Destination Network Address Translation) should be configured on the [[Hardware Node]]. To perform a simple DNAT setup, execute the following command on the [[Hardware Node]]:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# iptables -t nat -A PREROUTING -p tcp -d ip_address --port port_num \&lt;br /&gt;
  -i eth0 -j DNAT --to-destination ve_address:dst_port_num &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
where &amp;lt;tt&amp;gt;ve_address&amp;lt;/tt&amp;gt; is an IP address of the VE, &amp;lt;tt&amp;gt;dst_port_num&amp;lt;/tt&amp;gt; is a tcp port which requires service use, &amp;lt;tt&amp;gt;ip_address&amp;lt;/tt&amp;gt; is the external (public) IP address of your [[Hardware Node]], and &amp;lt;tt&amp;gt;port_num&amp;lt;/tt&amp;gt; is a tcp port of [[Hardware Node]], which will be used for Internet connections to private VE service. Note that this setup makes the service which is using &amp;lt;tt&amp;gt;port_num&amp;lt;/tt&amp;gt; on the [[Hardware Node]] be unaccessible from the Internet. Also note that SNAT translation is required too.&lt;br /&gt;
&lt;br /&gt;
For example, if you need a web server in a VE to be accessible from outside and, at the same time, keep a web server on the [[Hardware Node]] be accessible, use the following config:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# iptables -t nat -A PREROUTING -p tcp -d ip_address --dport 8080 \&lt;br /&gt;
  -i eth0 -j DNAT --to-destination ve_address:80&lt;br /&gt;
# iptables -t nat -A POSTROUTING -s ve_address -o eth0 -j SNAT --to ip_address&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After applying this, you'll see VE' web server at &amp;lt;code&amp;gt;&amp;lt;nowiki&amp;gt;http://ip_address:8080/&amp;lt;/nowiki&amp;gt;&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
The &amp;lt;tt&amp;gt;iptables&amp;lt;/tt&amp;gt; utility allows to set up more complex rules for Network Address Translation, involving various protocols and ports. If you wish to get more information on this, consult the numerous Internet sites (e.g. [http://www.netfilter.org netfilter.org]) and tutorials devoted to this issue.&lt;br /&gt;
&lt;br /&gt;
== External Links ==&lt;br /&gt;
* [http://www.netfilter.org netfilter.org]&lt;br /&gt;
&lt;br /&gt;
[[Category: HOWTO]]&lt;br /&gt;
[[Category: Networking]]&lt;/div&gt;</summary>
		<author><name>Hvdkamer</name></author>
		
	</entry>
</feed>