Skip to content

Latest commit

 

History

History
166 lines (144 loc) · 6.23 KB

offload_server_config.h

File metadata and controls

166 lines (144 loc) · 6.23 KB
 
Aug 31, 2008
Aug 31, 2008
1
2
// set these for your server, and put this file in the same directory as
// nph-offload.c ...
3
4
5
// GDEBUG should be false at production time, but this lets you sanity check
// some things before going live.
Aug 31, 2008
Aug 31, 2008
6
#ifndef GDEBUG
Aug 31, 2008
Aug 31, 2008
7
#define GDEBUG 0
Aug 31, 2008
Aug 31, 2008
8
#endif
Oct 7, 2008
Oct 7, 2008
10
// Set GDEBUGTOFILE to write all debug info to files in GDEBUGDIR, if
Sep 30, 2008
Sep 30, 2008
11
12
13
14
15
// GDEBUG is also true. You probably want this to be true most cases.
#ifndef GDEBUGTOFILE
#define GDEBUGTOFILE 1
#endif
Oct 7, 2008
Oct 7, 2008
16
17
18
19
20
21
// Ignore this if either GDEBUG or GDEBUGTOFILE are zero.
// Set GDEBUGDIR to where debug logs should be written.
#ifndef GDEBUGDIR
#define GDEBUGDIR "/usr/local/apache/logs"
#endif
Sep 30, 2008
Sep 30, 2008
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
// Set this to non-zero to provide a listen server that serves HTTP requests
// directly. Set this to zero and you need to run as a cgi-bin program
// through another webserver. Obviously, you can't listen on port 80 if
// something else is using it.
#ifndef GLISTENPORT
#define GLISTENPORT 0
#endif
// Ignore this if GLISTENPORT == 0. This is the address to bind to. It should
// be a string literal ("39.15.124.111" or maybe "localhost" if another
// process is proxying). NULL is equivalent to IN_ADDRANY; bind to everything.
#ifndef GLISTENADDR
#define GLISTENADDR NULL
#endif
// Ignore this if GLISTENPORT == 0. Should probably be PF_INET or PF_INET6.
#ifndef GLISTENFAMILY
#define GLISTENFAMILY PF_INET
#endif
// Ignore this if GLISTENPORT == 0.
// Set this to a list of IP addresses from which you trust the X-Forwarded-For
// header. This has to match this format:
// "xxx.xxx.xxx.xxx", "yyy.yyy.yyy.yyy", [...more like that...]
// ...an array of C string literals.
// If you don't plan to serve from behind a known proxy on your LAN, you
// can just set this to NULL.
#ifndef GLISTENTRUSTFWD
#define GLISTENTRUSTFWD "127.0.0.1", "0.0.0.0"
#endif
// Ignore this if GLISTENPORT == 0.
// Set this to non-zero to make process fork to background on startup.
#ifndef GLISTENDAEMONIZE
#define GLISTENDAEMONIZE 0
#endif
Oct 6, 2008
Oct 6, 2008
59
60
61
62
63
64
65
66
67
68
69
70
71
// This works everywhere, but you probably don't want it if GLISTENPORT == 0.
// Set this to non-zero to make each transaction append a line to a log file
// in Apache Combined Log Format.
#ifndef GLOGACTIVITY
#define GLOGACTIVITY 0
#endif
// Ignore this if GLOGACTIVITY == 0.
// Set this to the filename to write log data to. Put a full path here!
#ifndef GLOGFILE
#define GLOGFILE "/usr/local/apache/logs/access.log"
#endif
Oct 12, 2008
Oct 12, 2008
72
// This is the server that you are offloading's hostname.
Aug 31, 2008
Aug 31, 2008
73
#ifndef GBASESERVER
Sep 4, 2008
Sep 4, 2008
74
#define GBASESERVER "example.com"
Aug 31, 2008
Aug 31, 2008
75
#endif
Oct 12, 2008
Oct 12, 2008
77
78
79
80
81
82
83
84
85
86
// This is the server that you are offloading's IP address.
// We use this for DNS lookups (GBASESERVER is used for the "Host:" field in
// HTTP requests, etc). If you know the IP address will never change, you can
// save the several hundred kilobytes of address space that glibc uses...it
// loads a separate shared library for the DNS lookup, but it doesn't need
// to if GBASESERVERIP is an IP address in "xxx.xxx.xxx.xxx" format.
#ifndef GBASESERVERIP
#define GBASESERVERIP GBASESERVER
#endif
Sep 30, 2008
Sep 30, 2008
87
88
// This is the port on the base server to connect to (default for HTTP is 80).
#ifndef GBASESERVERPORT
Sep 30, 2008
Sep 30, 2008
89
#define GBASESERVERPORT 80
Sep 30, 2008
Sep 30, 2008
90
91
#endif
Sep 30, 2008
Sep 30, 2008
92
93
// Time in seconds that i/o (to base server or client) should timeout in
// lieu of activity.
Aug 31, 2008
Aug 31, 2008
94
#ifndef GTIMEOUT
Sep 30, 2008
Sep 30, 2008
95
#define GTIMEOUT 45
Aug 31, 2008
Aug 31, 2008
96
#endif
97
98
// This is where we'll cache files.
Aug 31, 2008
Aug 31, 2008
99
#ifndef GOFFLOADDIR
Aug 31, 2008
Aug 31, 2008
100
#define GOFFLOADDIR "/usr/local/apache/offload"
Aug 31, 2008
Aug 31, 2008
101
#endif
Sep 4, 2008
Sep 4, 2008
103
104
105
106
107
108
109
110
111
112
113
114
115
116
// Set GMAXDUPEDOWNLOADS to the number of concurrent connections one IP
// address can have for one download. This is largely meant to prevent
// download accelerators that open multiple connections that each grab a
// portion of the same file. Any connections over the limit are immediately
// rejected with a 403 Forbidden response explaining the issue.
// The same IP can download different files at the same time; we count the
// number of simultaneous accesses to the same URL from the same IP.
// Two people on two machines behind a NAT, downloading the same file, will
// look like a dupe.
// Set this to zero to disable it.
#ifndef GMAXDUPEDOWNLOADS
#define GMAXDUPEDOWNLOADS 1
#endif
Oct 1, 2008
Oct 1, 2008
117
118
119
120
121
122
// Set to 1 to try to change title in "ps" listings. It becomes:
// "offload: GET /my/url.whatever" (or whatever).
#ifndef GSETPROCTITLE
#define GSETPROCTITLE 1
#endif
Sep 4, 2008
Sep 4, 2008
123
124
125
126
127
128
129
130
131
// if you have a PowerPC, etc, flip this to 1.
#ifndef PLATFORM_BIGENDIAN
#if defined(__powerpc64__) || defined(__ppc__) || defined(__powerpc__) || defined(__POWERPC__)
#define PLATFORM_BIGENDIAN 1
#else
#define PLATFORM_BIGENDIAN 0
#endif
#endif
Sep 4, 2008
Sep 4, 2008
132
133
134
135
136
137
138
139
140
// Pick a unique name, letters and dashes.
// This should be unique for each cache, or you may have odd problems. So
// if you have two separate offload servers with their own unique caches on
// the same machine, you want to keep them separated.
// If you just want one offload server, the default is fine.
#ifndef SHM_NAME
#define SHM_NAME "mod-offload"
#endif
Oct 13, 2008
Oct 13, 2008
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
// You probably should leave this alone if you don't know what you're doing.
// Set this to non-zero to disable caching. This can be useful if you just
// want a lightweight HTTP server to handle the heavy lifting for large
// static files. For example, you could have Apache running on port 80 to
// handle most requests, so you get all the PHP, SSL, mod_*, .htaccess, etc
// goodness, but Apache eats several megabytes of RAM per connection when
// serving static files. If you have a multi-gigabyte static file, a client
// might consume that server's RAM for several hours to complete the
// transfer. Since most of the memory Apache consumes is irrelevant to
// sending static files, it might make sense to offload it to a lightweight
// process like this, with a 302 Redirect, and free up those resources for
// dynamic content. Very quickly you find yourself saving hundreds of
// megabytes.
// GNOCACHE changes a few rules. This process will no longer cache files, and
// GOFFLOADDIR refers to the DocumentRoot where files are read from. We will
// still do HTTP HEAD requests to the GBASESERVER for metadata, and to verify
// that we have access to the file (since we do no authorization
// ourselves). We access the file directly, instead of caching over HTTP, so
// be careful about file permissions, URI aliases, etc. This probably is only
// useful with GLISTENPORT != 0.
#ifndef GNOCACHE
#define GNOCACHE 0
#endif
165
// end of offload_server_config.h ...