howtoe.html 36 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896
  1. <ul>
  2. <li>3APA3A 3proxy tiny proxy server HowTo
  3. <br>Under construction, very incomplete
  4. <ul>
  5. <li><A HREF="#COMPILE">Compilation</A>
  6. <ul>
  7. <li><A HREF="#MSVC">How to compile 3proxy with Visual C++</A>
  8. <li><A HREF="#INTL">How to compile 3proxy with Intel C Compiler under Windows</A>
  9. <li><A HREF="#GCCWIN">How to compile 3proxy with GCC under Windows</A>
  10. <li><A HREF="#GCCUNIX">How to compile 3proxy with GCC under Unix/Linux</A>
  11. <li><A HREF="#CCCUNIX">How to compile 3proxy with Compaq C Compiler under Unix/Linux</A>
  12. </ul>
  13. <li><A HREF="#INSTALL">Proxy server installation and removal</A>
  14. <ul>
  15. <li><A HREF="#INSTNT">How to install/remove 3proxy under Windows NT/2000/XP</A>
  16. <li><A HREF="#INST95">How to install/remove 3proxy under Windows 95/98/ME</A>
  17. <li><A HREF="#INSTUNIX">How to install/remove 3proxy under Unix/Linux</A>
  18. </ul>
  19. <li><A HREF="#SERVER">Server configuration</A>
  20. <ul>
  21. <li><A HREF="#SAMPLE">Where to find configuration example</A>
  22. <li><A HREF="#LOGGING">How to set up logging</A>
  23. <li><A HREF="#LOGFORMAT">How to setup logging format</A>
  24. <li><A HREF="#LOGANALIZERS">How to use log analizers with 3proxy</A>
  25. <li><A HREF="#LAUNCH">How to start any of proxy services (HTTP, SOCKS etc)</A>
  26. <li><A HREF="#BIND">How to bind service to specific interface and port?</A>
  27. <li><A HREF="#AUTH">How to limit service access</A>
  28. <li><A HREF="#USERS">How to create user list</A>
  29. <li><A HREF="#ACL">How to limit user access to resources</A>
  30. <li><A HREF="#REDIR">How to manage redirections</A>
  31. <li><A HREF="#ROUNDROBIN">How to balance traffic between few external channgels?</A>
  32. <li><A HREF="#CHAIN">How to manage proxy chains</A>
  33. <li><A HREF="#BANDLIM">How to limit bandwidth</A>
  34. <li><A HREF="#TRAFLIM">How to limit traffic amount</A>
  35. <li><A HREF="#NETLIST">How to build network lists</A>
  36. <li><a href="#NSCACHING">How to configure name resolution and DNS caching</a>
  37. <li><a href="#IPV6">How to use IPv6</a>
  38. <li><a href="#CONNBACK">How to use connect back</a>
  39. </ul>
  40. <li><A HREF="#CLIENT">Client configuration</A>
  41. <li><A HREF="#ADMIN">Administering and information analisys</A>
  42. <ul>
  43. <li><A HREF="#NEWVERSION">How to obtain latest 3proxy version</A>
  44. <li><A HREF="#NTSERVICE">How to control 3proxy service under Windows NT/2000/XP</A>
  45. <li><A HREF="#ERRORS">Log error codes reference</A>
  46. </ul>
  47. <li><A HREF="#QUEST">How To ask quiestion not in How To?</A>
  48. </ul>
  49. <br>
  50. <ul>
  51. <hr>
  52. <li><A NAME="COMPILE">Compilation</A>
  53. <p>
  54. <ul>
  55. <li><A NAME="MSVC">How to compile 3proxy with Visual C++</A>
  56. <p>
  57. Extract source code files from 3proxy.tgz (with WinZip or another utility).
  58. Use nmake /f Makefile.msvc command
  59. </p>
  60. <li><A NAME="INTL">How to compile 3proxy with Intel C Compiler under Windows</A>
  61. <p>
  62. See <A HREF="#MSVC">How to compile 3proxy with Visual C++</A>
  63. Use Makefile.intl instead of Makefile.msvc
  64. </p>
  65. <li><A NAME="GCCWIN">How to compile 3proxy with GCC under Windows</A></li>
  66. <p>
  67. Extract source files from 3proxy.tgz (for example with tar -xzf 3proxy.tgz command if you have tar installed)
  68. Use make -f Makefile.win command.
  69. If you want to use POSIX emulation Cygwin library (normally you shouldn't) - use make -f Makefile.unix instead.
  70. Windows specific things (like installing as service) will not be available if compiled with Cygwin emulation.
  71. </p>
  72. <li><A NAME="GCCUNIX">How to compile 3proxy with GCC under Unix/Linux</A></li>
  73. <p>
  74. Use
  75. <pre>
  76. make -f Makefile.Linux
  77. </pre>
  78. for Linux or Cygwin, Makefile.Solaris* (depending on compiler version) for Solaris
  79. and Makefile.unix for different Unix-like OS. On BSD derivered systems make
  80. sure to use GNU make, sometimes it's called gmake instead of make.
  81. <br>Compilation is tested under FreeBSD/i386, NetBSD/i386, OpenBSD/i386,
  82. RH Linux/Alpha, Debian/i386, Gentoo/i386, Gentoo/PPC, Solaris/x86 but you
  83. shouldn't have problems under different Solaris, BSD or linux compatible systems.
  84. For different systems you may be required to patch Makefile or even source codes.
  85. If you want to use ODBC support, make sure to install ODBC for unix, remove -DNOODBC
  86. option from makefile compiler options and add ODBC library to linker variable.
  87. </p>
  88. </ul>
  89. <hr>
  90. <li><A NAME="CCCUNIX">How to compile 3proxy with Compaq C Compiler under Unix/Linux</A></li>
  91. <p>
  92. See <A HREF="#GCCUNIX">How to compile 3proxy with GCC under Unix/Linux</A>, use Makefile.ccc instead of Makefile.unix.
  93. </p>
  94. </ul>
  95. <hr>
  96. <li><A NAME="INSTALL">Proxy server installation and removal</A>
  97. <p>
  98. <ul>
  99. <li><A NAME="INSTNT">How to install/remove 3proxy under Windows NT/2000/XP</A>
  100. <p>
  101. Unpack 3proxy.zip to any directory, for example
  102. c:\Program Files\3proxy. If needed, create directory for storing log files,
  103. ODBC sources, etc. Create 3proxy.cfg in the 3proxy installation directory (See <A HREF="#SERVER">Server configuration</A>).
  104. If you use 3proxy before 0.6 Add
  105. <pre>
  106. service
  107. </pre>
  108. string into 3proxy.cfg. Now, start command prompt (cmd.exe).
  109. Change directory to 3proxy installation and run 3proxy.exe --install:
  110. <pre>
  111. D:\>C:
  112. C:\>cd C:\Program Files\3proxy
  113. C:\Program Files\3proxy>3proxy.exe --install
  114. </pre>
  115. Now, you should have 3proxy service installed and running. If service is not
  116. started, remove "service" string from 3proxy.cfg, run 3proxy.exe manually
  117. and correct all errors.
  118. </p><p>
  119. To remove 3proxy run 3proxy --remove:
  120. <pre>
  121. D:\>C:
  122. C:\>cd C:\Program Files\3proxy
  123. C:\Program Files\3proxy>net stop 3proxy
  124. C:\Program Files\3proxy>3proxy.exe --remove
  125. </pre>
  126. Now you can simply remove 3proxy installation directory.
  127. </p>
  128. <li><A NAME="INST95">How to install/remove 3proxy under Windows 95/98/ME</A>
  129. <p>
  130. Unpack 3proxy.zip to any directory, for example
  131. c:\Program Files\3proxy. If needed, create directory for storing log files,
  132. ODBC sources, etc. Create 3proxy.cfg in the 3proxy installation directory (See <A HREF="#SERVER">Server configuration</A>).
  133. Remove string
  134. <pre>
  135. service
  136. </pre>
  137. from 3proxy.cfg and add
  138. <pre>
  139. daemon
  140. </pre>
  141. if you want 3proxy to run in background.
  142. Create shortcut for 3proxy.exe and place it in autostart or add
  143. to registry with regedit.exe:
  144. <br>HKLM\Software\Microsoft\Windows\CurrentVersion\Run</br>
  145. Type: String
  146. <br>3proxy = "c:\Program Files\3proxy.exe" "C:\Program Files\3proxy.cfg"<br>
  147. You must use quotes if path contains space. If neccessary, restart Windows.
  148. If service is not started, check log. Remove "daemon" command from 3proxy.cfg,
  149. start 3proxy.exe manually and correct all errors.
  150. </p>
  151. <li><A NAME="INSTUNIX">How to install/remove 3proxy under Unix/Linux</A>
  152. <p>
  153. Complie 3proxy (see <A HREF="#COMPILE">Compilation</A>). Copy
  154. executables to any appropriate location (for example /usr/local/3proxy/sbin
  155. for servers and /usr/local/3proxy/bin for utilities).
  156. Create /usr/local/etc/3proxy.cfg.
  157. (see <A HREF="#SERVER">Server configuration</A>).
  158. You can change default configuration file location by specifing configuration file
  159. in 3proxy command line.
  160. Add 3proxy to system startup scripts.
  161. </p>
  162. </ul>
  163. <hr>
  164. <li><A NAME="SERVER">Server configuration</A>
  165. <p>
  166. <ul>
  167. <li><A NAME="SAMPLE">Where to find configuration example</A>
  168. <p>
  169. Server configuration example 3proxy.cfg.sample is in any 3proxy distribution.
  170. </p>
  171. <li><A NAME="LOGGING">How to set up logging</A>
  172. <p>
  173. 3proxy can log to stdout, file, ODBC datasource and
  174. syslog (Unix/Linux/Cygwin only). For using ODBC under Unix/Linux you must
  175. compile 3proxy with Unix ODBC libraries, see <A HREF="#COMPILE">Compilation</A>.
  176. You can control logging from 3proxy.cfg for all services or you can control
  177. logging of individual service, for example
  178. /usr/local/sbin/socks -l/var/log/socks.log starts SOCKS proxy with logging to file.
  179. For universal proxy (3proxy) log file rotation and archiving is supported.
  180. Log type is defined with "log" configuration file command or with
  181. -l switch on individual service invokation. log or -l is stdout logging.
  182. <pre>
  183. log filename
  184. </pre>
  185. and
  186. <pre>
  187. -lfilename
  188. </pre>
  189. specify filename for logging
  190. <pre>
  191. log @ident
  192. </pre>
  193. and
  194. <pre>
  195. -l@ident
  196. </pre>
  197. specify ident for syslog logging. If filename within "log" command contains
  198. '%' characters, it's processes as format specificator (see "logformat"). E.g.
  199. log c:\3proxy\logs\%y%m%d.log D creates file like c:\3proxy\logs\060729.log,
  200. date is generated based on local time.
  201. <pre>
  202. log &connstring
  203. </pre>
  204. specifies ODBC connection string, connstring is in format
  205. datasource,username,password (2 last are optional of
  206. datasource does not require or already has authentication information).
  207. Also, you must specify logformat to build SQL query, to insert recod into
  208. log, see <A HREF="#LOGFORMAT">How to setup logging format</A>
  209. </p>
  210. <p>
  211. Rotation and archiving may be set up with log, rotate ¨ archiver commands
  212. <pre>
  213. log filename LOGTYPE
  214. </pre>
  215. sets rotation type. LOGTYPE may be:
  216. <ul>
  217. <li>M, monthely
  218. <li>W, weekly
  219. <li>D, daily
  220. <li>H, hourly
  221. <li>‘, minutely
  222. </ul>
  223. <pre>
  224. rotate NUMBER
  225. </pre>
  226. specifies number of files in rotation (that is how many files to keep).
  227. <pre>
  228. archiver EXT COMMAND PARAMETERS
  229. </pre>
  230. Sets external archiver. EXT is extention of archived files
  231. (for example zip, gz, Z, rar etc) COMMAND and PARAMETERS are command
  232. to execute and command line PARAMETERS. Originale file is not deleted by
  233. 3proxy, this work is left for archiver.
  234. You can pass original filename to archiver with %F macro and archive filename with %A.
  235. Examples are located in
  236. 3proxy.cfg.sample
  237. </p>
  238. <li><A NAME="LOGFORMAT">How to setup logging format</A>
  239. <p>
  240. Since 0.3 version log format may be set with "logformat" command.
  241. First symbol of log format specifies format of date and time and
  242. should be L (LOCAL) or G (GMT - Grinwitch Meridian Time). Format
  243. string may contains some macro substitutions:
  244. <ul>
  245. <li> %y - Year (2 digits)
  246. <li> %Y - Year (4 digits)
  247. <li> %m - Month (2 digits)
  248. <li> %o - mOnth (3 letter abbriviation)
  249. <li> %d - Day (2 digits)
  250. <li> %H - Hour (2 digits)
  251. <li> %M - Minute (2 digits)
  252. <li> %S - Second (2 digits)
  253. <li> %t - Timestamp (seconds since January, 1 1970 00:00:00 GMT)
  254. <li> %. - Milliseconds
  255. <li> %z - Timezone in mail format (from GMT, '+' east, '-' west HHMM), For example Moscow winter time is +0300.
  256. <li> %U - Username ('-' if unknown).
  257. <li> %N - Service name (PROXY, SOCKS, POP3P, etc)
  258. <li> %p - Service port
  259. <li> %E - Error code (see. <A HREF="#ERRORS">Log error codes reference</A>)
  260. <li> %C - client IP
  261. <li> %c - client port
  262. <li> %R - target IP
  263. <li> %r - target port
  264. <li> %e - external IP address used to establish connection
  265. <li> %Q - requested IP
  266. <li> %q - requested port
  267. <li> %I - bytes received from target
  268. <li> %O - bytes sent to target
  269. <li> %n - host name from request
  270. <li> %h - hops before target (if redirection or chaning is used).
  271. see <A HREF="#CHAIN">How to use chains and parent proxies</A>)
  272. <li> %T - service specific text (for example URL requested). %X-YT
  273. where X and Y are positive numbers, only displays fields
  274. (space delimited) X to Y of the text. An example is %1-2T.
  275. </ul>
  276. Example:
  277. <pre>
  278. logformat "L%t.%. %N.%p %E %U %C:%c %R:%r %O %I %h %T"
  279. </pre>
  280. generates something like
  281. <p><font face="courier">
  282. 1042454727.0296 SOCK4.1080 000 3APA3A 127.0.0.1:4739 195.122.226.28:4739 505 18735 1 GET http://3proxy.org/ HTTP/1.1
  283. </font>
  284. <br>(no line breaks)
  285. </p>
  286. <p>
  287. If ODBC used, logformat should specify SQL command,
  288. to insert record into log, for example
  289. <p><pre>
  290. logformat "-\'+_GINSERT INTO proxystat VALUES (%t, '%c', '%U', %I)"</pre>
  291. <br>(no line breaks)
  292. <br>-\'+_ instructs to replace characters \ and ' with _
  293. </p>
  294. <li><A NAME="LOGANALIZERS">How to use log analizers with 3proxy</A>
  295. <p>
  296. Just make format of 3proxy logs compatible with format supported by your
  297. favourite log analizer. Examples of compatible logformats are:
  298. <br>
  299. For Squid access.log:
  300. <p><font face="courier">
  301. &quot;- +_G%t.%. %D %C TCP_MISS/200 %I %1-1T %2-2T %U DIRECT/%R application/unknown&quot;
  302. </p>
  303. or, more compatible format without %D
  304. <pre>
  305. &quot;- +_G%t.%. 1 %C TCP_MISS/200 %I %1-1T %2-2T %U
  306. DIRECT/%R application/unknown&quot;
  307. </pre>
  308. ISA 2000 proxy WEBEXTD.LOG (fields are TAB-delimited):
  309. <pre>
  310. &quot;- + L%C %U Unknown Y %Y-%m-%d %H:%M:%S
  311. w3proxy 3PROXY - %n %R %r %D
  312. %O %I http TCP %1-1T %2-2T - -
  313. %E - - -&quot;
  314. </pre>
  315. ISA 2004 proxy WEB.w3c (fields are TAB-delimited):
  316. <pre>
  317. &quot;- + L%C %U Unknown %Y-%m-%d %H:%M:%S
  318. 3PROXY - %n %R %r %D %O
  319. %I http %1-1T %2-2T - %E -
  320. - Internal External 0x0 Allowed&quot;
  321. </pre>
  322. ISA 2000/2004 firewall FWSEXTD.log (fields are TAB-delimited):
  323. <pre>
  324. &quot;- + L%C %U unnknown:0:0.0 N %Y-%m-%d
  325. %H:%M:%S fwsrv 3PROXY - %n %R %r
  326. %D %O %I %r TCP Connect - -
  327. - %E - - - - -&quot;
  328. </pre>
  329. HTTPD standard log (Apache and others):
  330. <p><font face="courier">
  331. &quot;-&quot;&quot;+_L%C - %U [%d/%o/%Y:%H:%M:%S %z] &quot;&quot;%T&quot;&quot; %E %I&quot;
  332. </p>
  333. or more compatible without error code
  334. <p><font face="courier">
  335. &quot;-&quot;&quot;+_L%C - %U [%d/%o/%Y:%H:%M:%S %z] &quot;&quot;%T&quot;&quot; 200 %I&quot;
  336. </p>
  337. <li><A NAME="LAUNCH">How to start any of proxy services (HTTP, SOCKS etc)</A>
  338. <p>
  339. 3proxy is distributed in 2 variants: as a set of standalone modules (proxy,
  340. socks, pop3p, tcppm, udppm) and as universal proxy server. These services are
  341. absolutely independant, and if you use 3proxy you needn't any of standalone
  342. modules.
  343. <br>Standalone modules are only configurable via command line interface while
  344. 3proxy uses configuration file. Many functions, such as ODBC logging, log
  345. rotation, access control, etc are only available in 3proxy, not in standalone
  346. proxies.
  347. Standalone module may be started from command line, for example:
  348. <pre>
  349. $/sbin/socks -l/var/log/socks.log -i127.0.0.1
  350. </pre>
  351. Starts SOCKS server binded to localhost ip, port 1080 with logging to
  352. /var/log/socks.log.
  353. You can get help for any standalone service with -? command line option.
  354. </p><p>
  355. If 3proxy is used you should start all services in 3proxy.cfg file. 3proxy.cfg
  356. is executed by 3proxy as a batch file. Example of 3proxy.cfg and command syntaxys
  357. can be found in
  358. 3proxy.cfg.sample.
  359. <pre>
  360. log /var/log/3proxy.log D
  361. rotate 30
  362. internal 127.0.0.1
  363. external 192.168.1.1
  364. proxy
  365. socks -p3129
  366. pop3p
  367. </pre>
  368. Starts 3 services: HTTP PROXY, SOCKS and POP3 PROXY. Each listens localhost
  369. interface with default port (3128 for HTTP, 1080 for SOCKS and 110 for POP3P)
  370. except socks started with port 3129.
  371. All logs are in file /var/log/3proxy.log (with daily date modification and
  372. rotation). 30 last files are stored.
  373. </p>
  374. <li><A NAME="BIND">How to bind service to specific interface and port?</A>
  375. <p>
  376. -i options specifies internal interface, -p - listening port. No space are
  377. allowed. To bind 'proxy' service to port 8080 on interfaces 192.168.1.1
  378. and 192.168.2.1 use
  379. <pre>
  380. proxy -p8080 -i192.168.1.1
  381. proxy -p8080 -i192.168.2.1
  382. </pre>
  383. </p>
  384. <li><A NAME="AUTH">How to limit service access</A>
  385. <p>
  386. First, always specify internal interface to accept incoming connection with
  387. 'internal' configuration command or '-i' service command. (See
  388. <A HREF="#LAUNCH">How to start any of proxy services (HTTP, SOCKS etc)</A>). If
  389. no internal interface is specified your proxy will act as open one.
  390. <p>It's also important to specify external interface to prevent access to
  391. internal network with 'external' or -e.
  392. <p>3proxy with configuration files allows to use authentication and
  393. authorization for user's access. Authentication is possible by
  394. username/password or user's NetBIOS name. Authentication type is specified by
  395. 'auth' command.
  396. <pre>
  397. auth none
  398. </pre>
  399. Disables both authentication and authorization. You can not use ACLs.
  400. <pre>
  401. auth iponly
  402. </pre>
  403. Specifies no authentication, ACLs authorization is used.
  404. <pre>
  405. auth nbname
  406. </pre>
  407. Authentication by NetBIOS name + ACLs. NetBIOS name of 'messenger' service
  408. is obrained before ACL validation. If no name is obtained it's assumed to be
  409. empty. Messenger is started by default in Windows NT/2000/XP. For Win9x
  410. WinPopUP need to be launched. This type of authentication may be spoofed
  411. by privileged local user.
  412. <pre>
  413. auth strong
  414. </pre>
  415. Authentication by username/password. If user is not registered his
  416. access is denied regardless of ACLs.
  417. <p>
  418. Different services can have different authentication levels.
  419. <pre>
  420. auth none
  421. pop3p
  422. auth iponly
  423. proxy
  424. auth strong
  425. socks
  426. </pre>
  427. It's possible to authorize access by client IP address, IP address or requested resource,
  428. target port, time, etc after authentication.
  429. (See <A HREF="#ACL">How to limit resource access</A>).
  430. </p><p>Since 0.6 version double authentication is possible, e.g.
  431. <pre>
  432. auth iponly strong
  433. allow * * 192.168.0.0/16
  434. allow user1,user2
  435. proxy
  436. </pre>
  437. strong authentication will only be used if ACL requires username to deside if
  438. access must be granted. That is, in example, strong username authentication
  439. is not required to access 192.168.0.0/16
  440. </p><p>0.6 version introduces authentication (username) caching to increase
  441. productivity. It's recommended to use authentication caching with resource
  442. or time consuming authentication types, such as nbname or external plugins
  443. (WindowsAuthentication).
  444. Caching can be set with 'authcache' command with 2 parameters: caching type
  445. and caching time (in seconds). Caching type defines the type of cached access:
  446. 'ip' - after successful authentication all connections during caching time
  447. from same IP are assigned to the same user, username is not requested.
  448. "ip,user" - username is requested and all connections from the same IP are
  449. assigned to the same user without actual authentication. "user" - same as above,
  450. but IP is not checked. "user,password" - username and password are checked
  451. against cached ones. For authentication special authentication type 'cache'
  452. must be used.
  453. Example:
  454. <pre>
  455. authcache ip 60
  456. auth cache strong windows
  457. proxy -n
  458. </pre>
  459. </p>
  460. Please note, that caching affects security. Never use caching for access to
  461. critical resources, such as web administration.
  462. <li><A NAME="USERS">How to create user list</A>
  463. <p>
  464. Userslist is created with 'users' command.
  465. <pre>
  466. users USERDESC ...
  467. </pre>
  468. With a single command it's possible to define few users, or you
  469. can use few 'users' commands. USERDESC is user description. Description
  470. consists of three semicolon delimited parts - login, password type and
  471. <pre>
  472. users admin:CL:bigsecret test:CL:password test1:CL:password1
  473. users "test2:CR:$1$lFDGlder$pLRb4cU2D7GAT58YQvY49."
  474. users test3:NT:BD7DFBF29A93F93C63CB84790DA00E63
  475. </pre>
  476. Please note the usage of quotation sign: it's required to comment out $ sign
  477. overwise used as a file inclusion macro.
  478. Next password types are available:
  479. <ul>
  480. <li>No password type: use system authentication.
  481. <li>CL - cleartext password
  482. <li>CR - crypt password, only MD5 crypt passwords are supported
  483. <li>NT - NT-hashed (MD4) passwords in hex, as used in pwdump or SAMBA
  484. </ul>
  485. NT and crypt passwords can be used to import accounts from Windows/SAMBA or
  486. Unix. For Windows you can use pwdump family of utilities.
  487. It's convenient to store accounts apart and include account file with $ macro.
  488. Because for included files newlines are treated as a space, it's possible to
  489. use atandard passwd file format:
  490. <pre>
  491. users $/etc/.3proxypasswd
  492. </pre>
  493. or
  494. <pre>
  495. users $"c:\Program Files\3proxy\passwords"
  496. </pre>
  497. It's possible to create NT and crypt passwords with mycrypt utility included
  498. in distribution.
  499. <br>Userlist is system-wide. To manage user access to specific service use ACLs.
  500. </p>
  501. <li><A NAME="ACL">How to limit user access to resources</A>
  502. <p>
  503. Commands allow, deny and flush are used to manage ACLs:
  504. <p><font face="courier">
  505. allow &lt;userlist&gt; &lt;sourcelist&gt; &lt;targetlist&gt; &lt;targetportlist&gt; &lt;commandlist&gt; &lt;weekdaylist&gt; &lt;timeperiodlist&gt;
  506. <br>deny &lt;userlist&gt; &lt;sourcelist&gt; &lt;targetlist&gt; &lt;weekdaylist&gt; &lt;timeperiodlist&gt;
  507. <br>flush
  508. </font>
  509. </p>
  510. 'flush' command is used to finish with existing ACL and to start new one.
  511. It's required to have different ACLs for different services.
  512. 'allow' is used to allow connection and 'deny' to deny connection. 'allow'
  513. command can be extended by 'parent' command to manage redirections (see <A NAME="REDIR">How to manage redirections</A>)). If ACL
  514. is empty it allow everything. If ACL is not empty, first matching ACL entry
  515. is searched for user request and ACL action (allow or deny) performed. If
  516. no matching record found, connection is denied and user will be asked to
  517. re-authenticate (requested for username/password). To prevent this request
  518. add 'deny *' to the end of list.
  519. <ul>
  520. <li>&lt;userlist&gt; - comma delimited list of users
  521. <li>&lt;sourcelist&gt; - comma delimited list of source (client) networks.
  522. Networks can be defined as single IP address or in CIDR form
  523. xxx.yyy.zzz.mmm/l, where l - is the length of network mask
  524. (a number of non-zero bits). 192.168.1.0/24
  525. means network with 255.255.255.0 mask.
  526. <li>&lt;targetlist&gt; - comma delimited list of target (server) networks.
  527. In 3proxy 0.6 and above it's allowed to use hostnames with wildmasks
  528. in targetlist. Wildmask may only present in the begginning or at the
  529. end of the hostname, e.g.
  530. 192.168.0.0/16,www.example.com,*wrongsite.com,*wrongcontent*.
  531. <li>&lt;targetportlist&gt; - comma delimited list of ports. I
  532. It's possible to define port ranges with -, e.g. 80,1024-65535
  533. means port 80 and all unprivileged ports.
  534. <li>&lt;commandlist&gt; - the list of allowed actions
  535. <br> CONNECT - establish outgoing TCP connection. e.g. POP3 or SOCKSv5
  536. <br> BIND - allow incoming TCP connection (SOCKSv5)
  537. <br> UDPASSOC - create UDP association (SOCKSv5)
  538. <br> ICMPASSOC - create ICMP association (not implemented)
  539. <br> HTTP_GET - HTTP GET request (HTTP proxy)
  540. <br> HTTP_PUT - HTTP PUT request (HTTP proxy)
  541. <br> HTTP_POST - HTTP POST request (HTTP proxy)
  542. <br> HTTP_HEAD - HTTP HEAD request (HTTP proxy)
  543. <br> HTTP_CONNECT - HTTP CONNECT, aka HTTPS request (HTTP proxy)
  544. <br> HTTP_OTHER - another HTTP request (HTTP proxy)
  545. <br> HTTP - any HTTP request except HTTP_CONNECT (HTTP proxy)
  546. <br> HTTPS - alias to HTTP_CONNECT (HTTP proxy)
  547. <br> FTP_GET - FTP get request (http, ftp proxy)
  548. <br> FTP_PUT - FTP put request (ftp proxy)
  549. <br> FTP_LIST - FTP list request (http, ftp proxy)
  550. <br> FTP - any FTP request
  551. <br> ADMIN - administration interface access
  552. <p>
  553. <li>&lt;weeksdays&gt; - week days numbers or periods (0 or 7 means Sunday, 1 is Monday, 1-5 means Monday through Friday).
  554. <li>&lt;timeperiodlists&gt; - a list of time periods in HH:MM:SS-HH:MM:SS format. For example,
  555. 00:00:00-08:00:00,17:00:00-24:00:00 lists non-working hours.
  556. </ul>
  557. * in ACL means &quot;any&quot;.
  558. Usage examples could be found in 3proxy.cfg.sample.
  559. </p>
  560. <li><A NAME="REDIR">How to manage redirections</A>
  561. <p>
  562. Redirections are usefull to e.g. forward requests from specific clients
  563. to different servers or proxy server. Additionally, redirections are usefull
  564. to convert proxy interface from ont format to another, e.g. requests from
  565. SOCKS proxy can be redirected to parent HTTP proxy, or SOCKSv5 client can be
  566. redirected to SOCKSv4 proxy.
  567. <br>Because 3proxy understand "transparent" web request, it can be used as an
  568. intermediate software between HTTP proxy and NAT server for transparent HTTP
  569. forwarding, because it can convert "Web server" request issued by client to
  570. "proxy request" required by proxy server. A simplest redirection is:
  571. <pre>
  572. auth iponly
  573. allow *
  574. parent 1000 http 192.168.1.1 3128
  575. proxy
  576. </pre>
  577. All trafiic of HTTP proxy is redirected to parent proxy 192.168.1.1 port 3128.
  578. <br>If port number is '0', IP address from 'parent' is used as external address
  579. for this connection (that is like -eIP, but only for connections matching
  580. 'allow').
  581. <br>Special case of redirection are local redirections. In this case both IP is
  582. 0.0.0.0 and port is 0. It's only usseful with SOCKS service. In this case no
  583. new connection is established, but request is parsed by corresponding local
  584. service. E.g.:
  585. <pre>
  586. auth iponly
  587. allow * * * 80
  588. parent 1000 http 0.0.0.0 0
  589. allow * * * 21
  590. parent 1000 ftp 0.0.0.0 0
  591. allow * * * 110
  592. parent 1000 pop3 0.0.0.0 0
  593. socks
  594. </pre>
  595. In this case all SOCKS traffic with destination port 80 is forwarded to local
  596. 'proxy' service, destination port 21 to 'ftppr' and 110 to 'pop3pr'. There is
  597. no need to run these services expicitly. Local redirections are usefull if
  598. you want to see and control via ACLs protocol specific parameters, e.g.
  599. filenames requests thorugh FTP while clients are using SOCKS.
  600. </p>
  601. <li><A NAME="ROUNDROBIN">How to balance traffic between few external channgels?</A>
  602. <p>
  603. Proxy itself doesn't manage network level routing. The only way to control
  604. outgoing channel is to select external interface. It's possible to make
  605. external interface (what is usually selected with 'external' command or
  606. '-e' option) random by using local redirection with external port 0.
  607. <pre>
  608. auth iponly
  609. allow *
  610. parent 500 http 10.1.1.101 0
  611. parent 500 http 10.2.1.102 0
  612. </pre>
  613. Now external interface is randomly selected with 0.5 probability between
  614. 10.1.1.101 and 10.2.1.102. To work as expected, different default routes
  615. must between 2 interfaces.
  616. used
  617. <p>
  618. If both interface addresses are in same network, e.g. 10.1.1.101 and 10.1.1.102
  619. and you want to select random gateway between 10.1.1.1 and 10.1.1.2, you must
  620. control it by using routing table, in case there is no default gateway route
  621. for Windows:
  622. <pre>
  623. route add -p 10.1.1.1 10.1.1.101
  624. route add -p 10.1.1.2 10.1.1.102
  625. route add -p 0.0.0.0 mask 0.0.0.0 192.168.1.1
  626. route add -p 0.0.0.0 mask 0.0.0.0 192.168.1.2
  627. </pre>
  628. If you have no second address yet, just add it. Under Linux/Unix it's better
  629. to use source routing.
  630. </p>
  631. <li><A NAME="CHAIN">How to manage proxy chains</A>
  632. <p>
  633. parent command may also be used to build a proxy chains. In this case
  634. few 'parent' commands are used for single 'allow' rule with different
  635. weights (first argument of parent command). Chain may contain any number
  636. of proxy servers, but it should be noted that every hope significantly
  637. reduces productivity. It's possible to mix different types of proxy within
  638. single chain: HTTPS (HTTP connect), SOCKS4, SOCKS5. Weight different from
  639. 1000 is used to build random chains. if weight W is below 1000, this proxy
  640. will be used as a next chain hop with probability of W/1000. That is, if
  641. the weight is 250 probability this proxy will be used for the next hope is
  642. 25%. 'parent' records with common weight of 1000 establish a group, one of
  643. these record will be used for the hop with probability according to weight.
  644. Warning: each group must have a weight even of 1000. As follows, common
  645. weight of all 'parent' records must also be even of 1000. If common weight
  646. of 'parent' records in te chain is 3000, chain has 3 hops and must be formed
  647. of 3 groups. Example:
  648. <pre>
  649. allow *
  650. parent 500 socks5 192.168.1.1 1080
  651. parent 500 connect 192.168.10.1 3128
  652. </pre>
  653. In this case we have 1 parent proxy (1 hop) which is randomely choosen between
  654. 2 hosts: 192.168.1.1 and 192.168.10.1. 2 records form a single group.
  655. <pre>
  656. allow * * * 80
  657. parent 1000 socks5 192.168.10.1 1080
  658. parent 1000 connect 192.168.20.1 3128
  659. parent 300 socks4 192.168.30.1 1080
  660. parent 700 socks5 192.168.40.1 1080
  661. </pre>
  662. In this case we have 3 groups (3 hops in the chain). First hop is 192.168.10.1,
  663. second hop is 192.168.20.1 and 3rd one is either 192.168.30.1 with probability
  664. of 30% or 192.168.40.1 with probability of 70%.
  665. </p>
  666. <li><A NAME="BANDLIM">How to limit bandwidth</A>
  667. <p>
  668. 3proxy supports bandwidth filters. To manage filters bandlimin/bandlimout and
  669. nobandlimin/nobandlimout. 'in' means incoming and 'out' - outgoing traffic.
  670. <p><font face="courier">
  671. bandlimin &lt;bitrate&gt; &lt;userlist&gt; &lt;sourcelist&gt; &lt;targetlist&gt; &lt;targetportlist&gt; &lt;commandlist&gt;
  672. <br>nobandlimin &lt;userlist&gt; &lt;sourcelist&gt; &lt;targetlist&gt; &lt;targetportlist&gt; &lt;commandlist&gt;
  673. </font>
  674. </p>
  675. Commands are applied to all services. Imagine bandwidth filters as a series of
  676. pipes. Bitrate is a pipe's width and ACLs controls the flow thorugh this pipe.
  677. <pre>
  678. bandlimin 57600 * 192.168.10.16
  679. bandlimin 57600 * 192.168.10.17
  680. bandlimin 57600 * 192.168.10.18
  681. bandlimin 57600 * 192.168.10.19
  682. </pre>
  683. Create 4 separete pipes for 4 client with emulation of modem connection.
  684. <pre>
  685. bandlimin 57600 * 192.168.10.16/30
  686. </pre>
  687. Create single pipe for all 4 clients. That is 4 clients share modem connection.
  688. In this example:
  689. <pre>
  690. nobandlimin * * * 110
  691. bandlimin 57600 * 192.168.10.16/32
  692. </pre>
  693. mail traffic from POP3 servers bypasses the pipe and has no bandwidth
  694. limitation.
  695. </p>
  696. <li><A NAME="TRAFLIM">How to limit traffic amount</A>
  697. <p>
  698. <p><font face="courier">
  699. counter &lt;filename&gt; &lt;type&gt; &lt;reportpath&gt;
  700. <br>countin &lt;number&gt; &lt;type&gt; &lt;amount&gt; &lt;userlist&gt; &lt;sourcelist&gt; &lt;targetlist&gt; &lt;targetportlist&gt; &lt;commandlist&gt;
  701. <br>nocountin &lt;userlist&gt; &lt;sourcelist&gt; &lt;targetlist&gt; &lt;targetportlist&gt; &lt;commandlist&gt;
  702. <br>countout &lt;number&gt; &lt;type&gt; &lt;amount&gt; &lt;userlist&gt; &lt;sourcelist&gt; &lt;targetlist&gt; &lt;targetportlist&gt; &lt;commandlist&gt;
  703. <br>nocountout &lt;userlist&gt; &lt;sourcelist&gt; &lt;targetlist&gt; &lt;targetportlist&gt; &lt;commandlist&gt;
  704. </font>
  705. </p>
  706. <p>
  707. You can set traffic limit per day (D), week (W), month (M), year (Y) or
  708. absolute ('N'), as specified by 'type' argument of counterin command.
  709. Traffic information is stored in binary file specified by 'filename' argument.
  710. countersutil utility can be used to manage this file.
  711. reportpath specifies location of text reports, type parameter of 'counter'
  712. command controls how often text reports are created. amount is amount of
  713. allowed traffic in Megabytes (MB). nocountin allows you to set exclusions.
  714. </p>
  715. <li><A NAME="NETLIST">How to build network lists</A>
  716. <p>Networks or users lists are often very huge. 3proxy doesn't currently
  717. supports user groups, but ones can be created by the means of include files.
  718. You can store comma-delimited lists of networks or users in the separate
  719. file and use $ macro to insert this list into 3proxy.cfg.
  720. 3proxy comes with 'dighosts'
  721. utility. This utility helps to grab the list of the network from HTTP page.
  722. It may be usefull to e.g. obtain a regullary updated list of local networks
  723. from ISP's server. A network list can be either in form of NETWORK MASK,
  724. e.g. 192.168.1.0 255.255.255.0 or NETWORK/LENGTH, e.g. 192.168.1.0/24. You can
  725. launch dighosts from 3proxy.cfg to be executed on every 3proxy startup or
  726. configuration reload:
  727. <pre>
  728. system "dighosts http://provider/network.html local.networks"
  729. allow * * $local.networks
  730. allow *
  731. parent 1000 proxy.provider 3128 *
  732. proxy
  733. flush
  734. </pre>
  735. In this example we obtain list of local networks from provider's page to
  736. local.networks file, allow direct access to these networks and redirect all
  737. connection to external networks to provider's proxy.
  738. </p>
  739. <li><a name="NSCACHING"><i>How to configure name resolution and DNS caching</i></a>
  740. <p>
  741. For name resolution and caching use commands nserver, nscache / nscache6 and nsrecord.
  742. <pre>
  743. nserver 192.168.1.2
  744. nserver 192.168.1.3:5353/tcp</pre>
  745. sets DNS resolvers. 192.168.1.3 will be used via TCP/5353 (instead of default UDP/53)
  746. only if 192.168.1.2 fails. Up to 5 nservers may be specified.
  747. If no nserver is configured, default system name resolution functions are used.
  748. <pre>
  749. nscache 65535
  750. nscache6 65535</pre>
  751. sets name cache size for IPv4 and IPv6. Name cache must be large enouth, if presents.
  752. name cache is only used if nserver is configured.
  753. <pre>
  754. nsrecord server.mycompany.example.com 192.168.1.1
  755. nsrecord www.porno.com 127.0.0.2
  756. ...
  757. deny * * 127.0.0.2</pre>
  758. adds static nsrecords. Also, static nsrecords are used for dnspr, unless -s option is specified.
  759. Since 0.8 version, parent proxy may be configured for dnspr.
  760. </p>
  761. <li><a name="IPV6"><i>How to use IPv6</i></a>
  762. <p>
  763. IPv6 is supported since 0.8. Please note, some proxy protolos, e.g. SOCKSv4,
  764. do not support IPv6. SOCKSv5 supports IPv6 with special request type (must be
  765. implemented by client).
  766. <br>
  767. 3proxy supports proxying from IPv4 and IPv6 networks to IPv4,
  768. IPv6 and mixed networks. IPv6 address may be used in
  769. internal, external, parent commands, ACLs, -i and -e options,etc.
  770. external command and -e options may be given twice for each service - once with IPv4
  771. and once with IPv6 address. internal can be given only once, to bind to all IPv4 and
  772. IPv6 addresses use [0:0:0:0:0:0:0:0] or [::].
  773. <br>
  774. Any service may be configured with -4, -46, -64, -6 options to specify decied
  775. priority for name to IPv4/IPv6 address resolution (IPv4 only, IPv4 priority,
  776. IPv6 priority, IPv6 only).
  777. </p>
  778. <li><a name="CONNBACK"><i>How to use connect back</i></a>
  779. <p>
  780. In example, users needs access from external network to proxy server located
  781. on the host 192.168.1.2. This host can not be accessed from external network,
  782. but it has access to external network with with external address 1.1.1.1.
  783. Also, user has access to the host 2.2.2.2 (IP address may be dynamic) with
  784. hostname host.dyndns.example.org via external network. User needs 2 instances
  785. of 3proxy, first one on the host 192.168.1.2 with config
  786. <pre>
  787. users user:CL:password
  788. auth strong
  789. allow user
  790. proxy -rhost.dyndns.example.org:1234</pre>
  791. second one on the host.dyndns.example.org (2.2.2.2) with config
  792. <pre>
  793. auth iponly
  794. allow * * 1.1.1.1
  795. tcppm -R0.0.0.0:1234 3128 1.1.1.1 3128</pre>
  796. For browser settings proxy is host.dyndns.example.org:3128.
  797. </p>
  798. </ul>
  799. <hr>
  800. <li><A NAME="CLIENT">Client configuration</A>
  801. <p>
  802. <hr>
  803. <li><A NAME="ADMIN">Administering and information analisys</A>
  804. <p>
  805. <ul>
  806. <li><A NAME="NEWVERSION">How to obtain latest 3proxy version</A>
  807. <p>
  808. Latest version of 3proxy may be obtained
  809. <A HREF="http://3proxy.org/">here</A>.
  810. New version may have changes and incompatibilities with previous one in files
  811. format or commands. Please, read CHANGELOG file and another documentation
  812. before installing new version.
  813. </p>
  814. <li><A NAME="NTSERVICE">How to control 3proxy service under Windows NT/2000/XP</A>
  815. <p>
  816. If installed as system service, 3proxy understands Windows service commands
  817. for START, STOP, PAUSE and RESUME. If service is PAUSEd, no new connections
  818. are accepted while older connections are processed. Currently there is no
  819. support for dynamic configuration change, so, you have to restart service
  820. completely if you have changed any configuration.
  821. You can control 3proxy service via "Services" administration ot via "net" command:
  822. <pre>
  823. net start 3proxy
  824. net stop 3proxy
  825. net pause 3proxy
  826. net continue 3proxy
  827. </pre>
  828. </p>
  829. <li><A NAME="ERRORS">Log error codes reference</A>
  830. <p>
  831. <ul>
  832. <li>0 - Operation successfully complited (connection
  833. was closed by one of peers)
  834. <li>1-9 - AUTHENTICATION ERRORS
  835. <li>1 - Access denied by ACL (deny)
  836. <li>2 - Redirection (should not appear)
  837. <li>3 - No ACL found, denied by default
  838. <li>4 - auth=strong and no username in request
  839. <li>5 - auth=strong and no matching username in configuration
  840. <li>6 - User found, wrong password (cleartext)
  841. <li>7 - User found, wrong password (crypt)
  842. <li>8 - User found, wrong password (NT)
  843. <li>9 - Redirection data not found (should not appear)
  844. <li>10 - Traffic limit exceeded
  845. <li>11-19 - CONNECTION ERRORS
  846. <li>11 - failed to create socket()
  847. <li>12 - failed to bind()
  848. <li>13 - failed to connect()
  849. <li>14 - failed to getpeername()
  850. <li>20-29 - COMMON ERRORS
  851. <li>21 - memory allocation failed
  852. <li>30-39 - CONNECT PROXY REDIRECTION ERRORS
  853. <li>31 - failed to request HTTP CONNECT proxy
  854. <li>32 - CONNECT proxy connection timed out or wrong reply
  855. <li>33 - CONNECT proxy fails to establish connection
  856. <li>34 - CONNECT proxy timed out or closed connection
  857. <li>40-49 - SOCKS4 PROXY REDIRECTION ERRORS
  858. <li>50-69 - SOCKS5 PROXY REDIRECTION ERRORS
  859. <li>70-79 PARENT PROXY CONNECTION ERRORS (identical to 1x)
  860. <li>90-99 - established connection errors
  861. <li>90 - socket error or connection broken
  862. <li>91 - TCP/IP common failure
  863. <li>92 - connection timed out
  864. <li>93 - error on reading data from server
  865. <li>94 - error on reading data from client
  866. <li>95 - timeout from bandlimin/bandlimout limitations
  867. <li>96 - error on sending data to client
  868. <li>97 - error on sending data to server
  869. <li>98 - server data limit (should not appear)
  870. <li>99 - client data limit (should not appear)
  871. <li>100 - HOST NOT FOUND
  872. <li>200-299 - UDP portmapper specific bugs
  873. <li>300-399 - TCP portmapper specific bugs
  874. <li>400-499 - SOCKS proxy specific bugs
  875. <li>500-599 - HTTP proxy specific bugs
  876. <li>600-699 - POP3 proxy specific bugs
  877. <li>999 - NOT IMPLEMENTED
  878. </ul>
  879. </p>
  880. </ul>
  881. <hr>
  882. <li><A NAME="QUEST">How To ask quiestion not in How To?</A>
  883. <p>
  884. Ask it in <A HREF="https://github.com/z3APA3A/3proxy/issues">Github</A>.
  885. Don't try to ask something before reading this document.
  886. </ul>
  887. </ul>