这将是我第一个问题。
在我们公司,我们使用Squid作为内部网和互联网之间的代理。 现在我们需要一个软件包无法处理代理服务器 – 它需要直接访问互联网。
所以我的想法是使用lighttpd作为这个应用程序和互联网之间的“桥梁”。 因此,应用程序可以调用“mylighttpd:91234”,并看到例如Google页面 – 浏览器中的地址仍然是“mylighttpd:91234”。
这就是我的lighttpd.conf的样子:
config { var.PID = 13793 var.CWD = "/home/testusr" var.log_root = "/tmp/lighttpd-log" var.server_root = "/tmp/lighttpd-data" var.state_dir = "/tmp/lighttpd-var/run" var.home_dir = "/var/lib/lighttpd" var.conf_dir = "/etc/lighttpd" var.vhosts_dir = "/tmp/lighttpd-data/vhosts" var.cache_dir = "/var/cache/lighttpd" var.socket_dir = "/var/lib/lighttpd/sockets" server.modules = ( "mod_indexfile", "mod_access", "mod_proxy", "mod_status", "mod_accesslog", "mod_redirect", "mod_rewrite", "mod_accesslog", "mod_dirlisting", "mod_staticfile", # 10 ) server.port = 91234 server.use-ipv6 = "disable" server.username = "testusr" server.groupname = "testgroup" server.document-root = "/tmp/lighttpd-data/htdocs" server.pid-file = "/tmp/lighttpd-var/run/lighttpd.pid" server.errorlog = "/tmp/lighttpd-log/error.log" accesslog.filename = "/tmp/lighttpd-log/access.log" server.event-handler = "linux-sysepoll" server.network-backend = "linux-sendfile" server.max-fds = 2048 server.stat-cache-engine = "simple" server.max-connections = 1024 index-file.names = ("index.xhtml", "index.html", "index.htm", "default.htm", "index.php") url.access-deny = ("~", ".inc") url.redirect = ( "^/(.*)" => "http://google.com/$1", ) proxy.debug = 1 proxy.server = ( "" => ( ( "host" => "192.168.1.10", "port" => 8080, # 2 ), ), ) static-file.exclude-extensions = (".php", ".pl", ".fcgi", ".scgi") mimetype.use-xattr = "disable" mimetype.assign = ( ".pdf" => "application/pdf", ".sig" => "application/pgp-signature", ".spl" => "application/futuresplash", ".class" => "application/octet-stream", ".ps" => "application/postscript", # 5 ".torrent" => "application/x-bittorrent", ".dvi" => "application/x-dvi", ".gz" => "application/x-gzip", ".pac" => "application/x-ns-proxy-autoconfig", ".swf" => "application/x-shockwave-flash", # 10 ".tar.gz" => "application/x-tgz", ".tgz" => "application/x-tgz", ".tar" => "application/x-tar", ".zip" => "application/zip", ".mp3" => "audio/mpeg", # 15 ".m3u" => "audio/x-mpegurl", ".wma" => "audio/x-ms-wma", ".wax" => "audio/x-ms-wax", ".ogg" => "application/ogg", ".wav" => "audio/x-wav", # 20 ".gif" => "image/gif", ".jpg" => "image/jpeg", ".jpeg" => "image/jpeg", ".png" => "image/png", ".xbm" => "image/x-xbitmap", # 25 ".xpm" => "image/x-xpixmap", ".xwd" => "image/x-xwindowdump", ".css" => "text/css", ".html" => "text/html", ".htm" => "text/html", # 30 ".js" => "text/javascript", ".asc" => "text/plain", ".c" => "text/plain", ".cpp" => "text/plain", ".log" => "text/plain", # 35 ".conf" => "text/plain", ".text" => "text/plain", ".txt" => "text/plain", ".spec" => "text/plain", ".dtd" => "text/xml", # 40 ".xml" => "text/xml", ".mpeg" => "video/mpeg", ".mpg" => "video/mpeg", ".mov" => "video/quicktime", ".qt" => "video/quicktime", # 45 ".avi" => "video/x-msvideo", ".asf" => "video/x-ms-asf", ".asx" => "video/x-ms-asf", ".wmv" => "video/x-ms-wmv", ".bz2" => "application/x-bzip", # 50 ".tbz" => "application/x-bzip-compressed-tar", ".tar.bz2" => "application/x-bzip-compressed-tar", ".rpm" => "application/x-rpm", "" => "application/octet-stream", # 54 ) dir-listing.activate = "disable" dir-listing.hide-dotfiles = "disable" dir-listing.exclude = ("~$") dir-listing.encoding = "UTF-8" dir-listing.hide-header-file = "disable" dir-listing.show-header = "disable" dir-listing.hide-readme-file = "disable" dir-listing.show-readme = "disable" server.follow-symlink = "enable" server.upload-dirs = ("/var/tmp") $HTTP["url"] =~ "\.pdf$" { # block 1 server.range-requests = "disable" } # end of $HTTP["url"] =~ "\.pdf$" }
鉴于:* 91234:端口是lighttpd侦听的地方* 192.168.1.10:Squid代理的IP * www.google.de:页面lighttpd应该通过代理转发。
目前,当我在浏览器中input“localhost:9123”时,它会打开Google页面,但会将其地址replace为www.google.com,并保留在“localhost:9123”处。
我已经阅读了关于转发,redirect和代理的lighttpd和Apache的文档,但我不能说这个不同 – 它根本不会进入我的脑海。
感谢您的帮助和理解。
只需设置拦截 ,将来自该服务器的所有出站请求redirect到鱿鱼。 这是不平凡的,你可能甚至需要为它build立第二个squid服务器,但是比上面提到的要less得多,它甚至使用了你已经熟悉的工具。
我现在用Apache解决了它。 这是configuration文件的小窍门:
<VirtualHost *:80> ... ProxyRemote * http://proxy.example.com:8080 ProxyPass / http://google.com/ ProxyPassReverse / http://google.com/ RewriteEngine on RewriteRule ^(.*)$ http://www.google.com/$1 [P] </VirtualHost>