Não é iptables
solution mas funciona:)
A solução é usar apache
modules mod_proxy.so
e mod_proxy_http.so
Instale o mod_proxy e configure o proxy reverso no Apache Webserver
Instale o módulo
sudo apt-get install libapache2-mod-proxy-html
Instalando a dependência libxml2-dev
apt-get install libxml2-dev
Carregue o módulo
a2enmod proxy proxy_http
Crie o host virtual no arquivo de configuração do apache.
sudo nano /etc/apache2/sites-enabled/000-default
Listen 40000
Listen 30000
<VirtualHost *:25565>
ServerName domain1.com
ServerAlias www.domain1.com
DocumentRoot /var/www/vhosts/domain1.com
<Directory /var/www/vhosts/domain1.com>
Options -Indexes FollowSymLinks -MultiViews
AllowOverride All
Order deny,allow
Allow from all
</Directory>
CustomLog /var/log/httpd/domain1.com-access.log combined
ErrorLog /var/log/httpd/domain1.com-error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
ProxyPass / http://domain1.com:40000/
ProxyPassReverse / http://domain1.com:40000/
</VirtualHost>
<VirtualHost *:40000>
ServerName domain1.com
ServerAlias www.domain1.com
#### This is where you put your files for that domain: /var/www/vhosts/domain1.com
DocumentRoot /var/www/vhosts/domain1.com
</VirtualHost>
<VirtualHost *:25565>
ServerName domain2.com
ServerAlias www.domain2.com
DocumentRoot /var/www/vhosts/domain1.com
<Directory /var/www/vhosts/domain2.com>
Options -Indexes FollowSymLinks -MultiViews
AllowOverride All
Order deny,allow
Allow from all
</Directory>
CustomLog /var/log/httpd/domain2.com-access.log combined
ErrorLog /var/log/httpd/domain2.com-error.log
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn
ProxyPass / http://domain2.com:30000/
ProxyPassReverse / http://domain2.com:30000/
</VirtualHost>
<VirtualHost *:30000>
ServerName domain2.com
ServerAlias www.domain2.com
#### This is where you put your files for that domain: /var/www/vhosts/domain2.com
DocumentRoot /var/www/vhosts/domain2.com
</VirtualHost>
Agora reinicie o apache
/etc/init.d/apache2 restart
Só resta negar o acesso com iptables
para a rede externa nas portas 30000
e 40000
porque apache
use localhost
.