Linux bridging Question

mbs

Expert Member
Joined
Nov 19, 2003
Messages
2,246
I remember this one from a while back when fiddling with RH - I think it's a question asking if you want to run XF86config (or whatever) to configure the X server, which currently has settings that don't match with your hardware...
 

b3dlam

Active Member
Joined
Sep 2, 2004
Messages
44
mbs when u mentioned what u said about hardware, the penny dropped. it always happened after i reinstalled and configured a network inf that the install didnt pick up.

swapped out network cards, busy checking if that was the prob.
 

andres101

Expert Member
Joined
May 14, 2004
Messages
2,124
loosecannon, thanks for that script!! i never knew that was possible. i set it up on our server but couldn't get it to work. i did some diggin and found that a request was coming in for "/proxy.pa" and not "/proxy.pac". aparently an IE bug...

i just copied proxy.pac to proxy.pa and added the line "AddType application/x-ns-proxy-autoconfig .pa" to apache conf. (just in case anyone else has the problem)
 

loosecannon

Senior Member
Joined
Jul 27, 2004
Messages
731
pleasure to be of assistance yip that is a bug in IE ... to get arround it i do the following in apache

RewriteCond %{HTTP_HOST} ^([^.]*).*$
RewriteCond %{REQUEST_URI} ^/wpad.da$ [OR]
RewriteCond %{REQUEST_URI} ^/wpad.dat$ [OR]
RewriteCond %{REQUEST_URI} ^/proxy.pa$ [OR]
RewriteCond %{REQUEST_URI} ^/proxy.pac$ [OR]
RewriteCond %1 ^wpad$
RewriteRule /(.*)$ /var/spool/apache/htdocs/proxy.pac [L]

this also allows wpad.<DOMAIN> <host>/wpad.dat <HOST>/wpad.da .... so iif i was to put the auto config script in a browser ill put "http://wpad.networksentry.co.za" apache dies the rest ...


dont forget to turn modrewirite on in httpd.conf
RewriteEngine On
RewriteLog /var/log/rewrite.log
RewriteLogLevel 0
RewriteMap lowercase int:tolower

bellow find my recipe for mass hosting of domains and users with custom layouts without ever restarting apache to add more domains ...
and no virtualhost declerations .... some links are frotpage specific admin/passwd pages

<blockquote id="quote"><font size="1" face="Verdana, Arial, Helvetica" id="quote">quote:<hr height="1" noshade id="quote">
&lt;IfModule mod_rewrite.c&gt;
RewriteEngine On
RewriteLog /var/log/rewrite.log
RewriteLogLevel 0
RewriteMap lowercase int:tolower
RewriteMap vhost dbm:/etc/apache/vhosts

RewriteRule ^/icons$ icons/ [R]
RewriteRule ^/fphelp$ fphelp/ [R]

RewriteRule (.*)/fpadmin$ $1/_vti_bin/_vti_adm/fpadmcgi.exe [L]
RewriteRule (.*)/pwadmin$ $1/_vti_bin/_vti_aut/passwd.htm [L]

RewriteCond %{REQUEST_URI} !^/icons
RewriteCond %{REQUEST_URI} !^/[a-z0-9\-\.]+/cgi-bin
RewriteCond ${lowercase:%{HTTP_HOST}} !^firewall.networksentry.co.za$
RewriteCond ${lowercase:%{HTTP_HOST}} ^([^.]*).*$
RewriteCond %1 ^home$ [OR]
RewriteCond %1 ^users$
RewriteCond %{REQUEST_URI} ^/(([a-z0-9\-\.])([a-z0-9\-\.])[a-z0-9\-\.]+)(.*)$
RewriteCond /var/home/%2/%3/%1/public_html -d
RewriteRule ^/(([a-z0-9\-\.])([a-z0-9\-\.])[a-z0-9\-\.]+)(.*)$ /var/home/$2/$3/$1/public_html$4 [L]

RewriteCond %{REQUEST_URI} ^/[a-z0-9\-\.]+/cgi-bin
RewriteCond ${lowercase:%{HTTP_HOST}} !^firewall.networksentry.co.za$
RewriteCond ${lowercase:%{HTTP_HOST}} ^([^.]*).*$
RewriteCond %1 ^home$ [OR]
RewriteCond %1 ^users$
RewriteCond %{REQUEST_URI} ^/(([a-z0-9\-\.])([a-z0-9\-\.])[a-z0-9\-\.]+)(.*)$
RewriteCond /var/home/%2/%3/%1/public_html -d
RewriteRule ^/(([a-z0-9\-\.])([a-z0-9\-\.])[a-z0-9\-\.]+)(.*)$ /var/home/$2/$3/$1/public_html$4 [T=application/x-httpd-cgi]

RewriteCond %{HTTP_HOST} ^([^.]*).*$
RewriteCond %{REQUEST_URI} ^/wpad.da$ [OR]
RewriteCond %{REQUEST_URI} ^/wpad.dat$ [OR]
RewriteCond %{REQUEST_URI} ^/proxy.pa$ [OR]
RewriteCond %{REQUEST_URI} ^/proxy.pac$ [OR]
RewriteCond %1 ^wpad$
RewriteRule /(.*)$ /var/spool/apache/htdocs/proxy.pac [L]

RewriteCond ${lowercase:%{HTTP_HOST}} ^([^.]*).*$
RewriteCond %{REQUEST_URI} !^/icons
RewriteCond %{REQUEST_URI} !^/horde
RewriteCond ${lowercase:%{HTTP_HOST}} !^firewall.networksentry.co.za$
RewriteCond %1 ^horde$ [OR]
RewriteCond %1 ^mail$ [OR]
RewriteCond %1 ^webmail$
RewriteRule ^/(.*)$ /var/spool/apache/htdocs/horde/$1 [L]

RewriteCond ${lowercase:%{HTTP_HOST}} ^([^.]*).*$
RewriteCond %{REQUEST_URI} !^/icons
RewriteCond %{REQUEST_URI} !^/horde
RewriteCond %{REQUEST_URI} !^/phpBB2
RewriteCond ${lowercase:%{HTTP_HOST}} !^firewall.networksentry.co.za$
RewriteCond %1 ^forum$
RewriteRule ^/(.*)$ /var/spool/apache/htdocs/phpBB2/$1 [L]

RewriteCond %{REQUEST_URI} !^/cgi-bin
RewriteCond %{REQUEST_URI} !^/icons
RewriteCond %{REQUEST_URI} !^/horde
RewriteCond %{REQUEST_URI} !^/~
RewriteCond ${lowercase:%{HTTP_HOST}} ^([^:]*).*$
RewriteCond ${vhost:%1|NULL} -d
RewriteRule ^/(.*)$ ${vhost:%1}/$1 [L]

RewriteCond %{REQUEST_URI} ^/cgi-bin
RewriteCond ${lowercase:%{HTTP_HOST}} ^([^:]*).*$
RewriteCond ${vhost:%1|NULL} -d
RewriteRule ^/(.*)$ ${vhost:%1}/$1 [T=application/x-httpd-cgi] [L]

RewriteCond %{REQUEST_URI} !^/icons
RewriteCond %{REQUEST_URI} !^/fphelp
RewriteCond %{REQUEST_URI} !^/_vti_bin
RewriteCond %{REQUEST_URI} !^/~
RewriteCond %{REQUEST_URI} !^/horde
RewriteCond ${lowercase:%{HTTP_HOST}} ^([^:]*).*$
RewriteCond /var/spool/apache/vhosts/${vhost:%1|NULL} -d
RewriteRule ^/(.*)$ /var/spool/apache/vhosts/${vhost:%1}/$1 [L]

RewriteCond %{REQUEST_URI} !^/icons
RewriteCond %{REQUEST_URI} !^/cgi-bin
RewriteCond ${lowercase:%{HTTP_HOST}} !^firewall.networksentry.co.za$
RewriteCond %{HTTP_HOST} ^(([a-z0-9\-])([a-z0-9\-])[a-z0-9\-]+).*$
RewriteCond /var/home/%2/%3/%1/public_html -d
RewriteRule ^/(.*)$ /var/home/%2/%3/%1/public_html/$1 [L]

RewriteCond %{REQUEST_URI} ^/cgi-bin
RewriteCond ${lowercase:%{HTTP_HOST}} !^firewall.networksentry.co.za$
RewriteCond %{HTTP_HOST} ^(([a-z0-9\-])([a-z0-9\-])[a-z0-9\-]+).*$
RewriteCond /var/home/%2/%3/%1/public_html -d
RewriteRule ^/(.*)$ /var/home/%2/%3/%1/public_html/$1 [T=application/x-httpd-cgi]

RewriteCond %{REQUEST_URI} !^/icons
RewriteCond %{REQUEST_URI} !^/[a-z0-9\-\.]+/cgi-bin
RewriteCond %{REQUEST_URI} !^/cgi-bin
RewriteCond %{REQUEST_URI} ^/(([a-z0-9\-\.])([a-z0-9\-\.])[a-z0-9\-\.]+)(.*)$
RewriteCond /var/home/%2/%3/%1/public_html -d
RewriteCond /var/spool/apache/htdocs/%1 !-d
RewriteCond ${lowercase:%{HTTP_HOST}} ^([^.]*).*$
RewriteCond %1 !^home$
RewriteCond %1 !^users$
RewriteRule ^/(([a-z0-9\-\.])([a-z0-9\-\.])[a-z0-9\-\.]+)(.*)$ /var/home/$2/$3/$1/public_html$4 [L]

RewriteCond %{REQUEST_URI} !^/cgi-bin
RewriteCond %{REQUEST_URI} ^/[a-z0-9\-\.]+/cgi-bin
RewriteCond %{REQUEST_URI} ^/(([a-z0-9\-\.])([a-z0-9\-\.])[a-z0-9\-\.]+)(.*)$
RewriteCond /var/home/%2/%3/%1/public_html -d
RewriteCond /var/spool/apache/htdocs/%1 !-d
RewriteCond ${lowercase:%{HTTP_HOST}} ^([^.]*).*$
RewriteCond %1 !^home$
RewriteCond %1 !^users$
RewriteRule ^/(([a-z0-9\-\.])([a-z0-9\-\.])[a-z0-9\-\.]+)(.*)$ /var/home/$2/$3/$1/public_html$4 [T=application/x-httpd-cgi] [L]

RewriteCond %{REQUEST_URI} ^/[~][a-z0-9\-\.]+/cgi-bin
RewriteCond %{REQUEST_URI} ^/[~](([a-z0-9\-\.])([a-z0-9\-\.])[a-z0-9\-\.]+)(.*)$
RewriteCond /var/home/%2/%3/%1/public_html -d
RewriteRule ^/[~](([a-z0-9\-\.])([a-z0-9\-\.])[a-z0-9\-\.]+)(.*)$ /var/home/$2/$3/$1/public_html$4 [T=application/x-httpd-cgi] [L]

RewriteCond ${lowercase:%{HTTP_HOST}} ^([^:]*).*$
RewriteCond ${vhost:%1|NULL} !-d
RewriteCond /var/spool/apache/vhosts/${vhost:%1|NULL} !-d
RewriteCond %{REQUEST_URI} !^/icons
RewriteCond %{REQUEST_URI} !^/cgi-perl
RewriteCond %{REQUEST_URI} !^/perl
RewriteCond %{REQUEST_URI} !^/~
RewriteCond %{REQUEST_URI} !^/[a-z0-9\-\.]+/cgi-bin
RewriteCond %{REQUEST_URI} !^/cgi-bin
RewriteCond ${lowercase:%{HTTP_HOST}} ^([^.]*).*$
RewriteCond %1 !^horde$
RewriteCond %1 !^mail$
RewriteCond %1 !^webmail$
RewriteRule ^/(.*)$ /var/spool/apache/htdocs/$1 [L]

&lt;/IfModule&gt;
<hr height="1" noshade id="quote"></blockquote id="quote"></font id="quote">
 

regardtv

Expert Member
Joined
Sep 1, 2003
Messages
1,537
hehe - you and your regular expressions spend WAY too much time together ... nice though ;-)
 

regardtv

Expert Member
Joined
Sep 1, 2003
Messages
1,537
As far as the mail server setting go ... I tend to capture outgoing smtp and re-direct to local SMTP server on the linux box. That way corporate policy/virri/etc can still be implemented cleanly.
 

loosecannon

Senior Member
Joined
Jul 27, 2004
Messages
731
i just block all outgoing SMTP on the gateway except from the mail server [if not gateway] setting up that recipe is years of work and looking at those regexes i can almost understand why i am the way i am ...

here are some of the mutations the above allows for

horde|mail|webmail.&lt;DOMAIN&gt; go straight to horde main page ...
&lt;USER&gt;.&lt;DOMAIN&gt; goes to ~user/public_html
&lt;DOMAIN&gt;/&lt;USER&gt; if not in a vhost/htdocs goes to ~user/public_html
home|users.&lt;DOMAIN&gt;/&lt;USER&gt; goes to ~user/public_html unconditionaly
&lt;VHOST&gt; goes to ~user/&lt;VHOST&gt; ie the website is stored in the owners home directory [makes chrooted ftp easy]
&lt;FPVHOST&gt; goes to the vhost directory in the web root and has no php/cgi/ftp capabilities only FP
the traditional &lt;DOMAIN&gt;/~&lt;USER&gt; is also allowed with /cgi-bin via suexec ...
cgi via suexec is allowed for both vhosts and users ...
forum.&lt;DOMAIN&gt; goes to phpBB2 ...

icons for directory listing are no maped so all /icons will be mapped to the icons directory to ensure eye candy is correct and the icons folder need
not be replicated ...

i have webaliser generate logs/graphs for all virtual hosts and
&lt;HOST&gt;/usage will get you into them but they are not part of the web tree ...

it is basicaly apache on steroids
 

andres101

Expert Member
Joined
May 14, 2004
Messages
2,124
some nice regex there! since you posted it here i will asume that you don't mind lazy ppl copy/paste 'ing...
 

loosecannon

Senior Member
Joined
Jul 27, 2004
Messages
731
no please go ahead im assumeing you have already :)

any mistakes please let me know ...

and note my user dirs are /var/home/a/b/abcuser
 
Top