Saltstack Official Apache Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

366 lines
12KB

  1. {% from "apache/map.jinja" import apache with context %}
  2. #
  3. # This is the main Apache HTTP server configuration file. It contains the
  4. # configuration directives that give the server its instructions.
  5. # See <URL:http://httpd.apache.org/docs/2.4/> for detailed information.
  6. # In particular, see
  7. # <URL:http://httpd.apache.org/docs/2.4/mod/directives.html>
  8. # for a discussion of each configuration directive.
  9. #
  10. # Do NOT simply read the instructions in here without understanding
  11. # what they do. They're here only as hints or reminders. If you are unsure
  12. # consult the online docs. You have been warned.
  13. #
  14. # Configuration and logfile names: If the filenames you specify for many
  15. # of the server's control files begin with "/" (or "drive:/" for Win32), the
  16. # server will use that explicit path. If the filenames do *not* begin
  17. # with "/", the value of ServerRoot is prepended -- so 'log/access_log'
  18. # with ServerRoot set to '/www' will be interpreted by the
  19. # server as '/www/log/access_log', where as '/log/access_log' will be
  20. # interpreted as '/log/access_log'.
  21. #
  22. # ServerRoot: The top of the directory tree under which the server's
  23. # configuration, error, and log files are kept.
  24. #
  25. # Do not add a slash at the end of the directory path. If you point
  26. # ServerRoot at a non-local disk, be sure to specify a local disk on the
  27. # Mutex directive, if file-based mutexes are used. If you wish to share the
  28. # same ServerRoot for multiple httpd daemons, you will need to change at
  29. # least PidFile.
  30. #
  31. ServerRoot "/etc/httpd"
  32. #
  33. # Listen: Allows you to bind Apache to specific IP addresses and/or
  34. # ports, instead of the default. See also the <VirtualHost>
  35. # directive.
  36. #
  37. # Change this to Listen on specific IP addresses as shown below to
  38. # prevent Apache from glomming onto all bound IP addresses.
  39. #
  40. #Listen 12.34.56.78:80
  41. Listen 80
  42. #
  43. # Dynamic Shared Object (DSO) Support
  44. #
  45. # To be able to use the functionality of a module which was built as a DSO you
  46. # have to place corresponding `LoadModule' lines at this location so the
  47. # directives contained in it are actually available _before_ they are used.
  48. # Statically compiled modules (those listed by `httpd -l') do not need
  49. # to be loaded here.
  50. #
  51. # Example:
  52. # LoadModule foo_module modules/mod_foo.so
  53. #
  54. Include conf.modules.d/*.conf
  55. #
  56. # If you wish httpd to run as a different user or group, you must run
  57. # httpd as root initially and it will switch.
  58. #
  59. # User/Group: The name (or #number) of the user/group to run httpd as.
  60. # It is usually good practice to create a dedicated user and group for
  61. # running httpd, as with most system services.
  62. #
  63. User apache
  64. Group apache
  65. # 'Main' server configuration
  66. #
  67. # The directives in this section set up the values used by the 'main'
  68. # server, which responds to any requests that aren't handled by a
  69. # <VirtualHost> definition. These values also provide defaults for
  70. # any <VirtualHost> containers you may define later in the file.
  71. #
  72. # All of these directives may appear inside <VirtualHost> containers,
  73. # in which case these default settings will be overridden for the
  74. # virtual host being defined.
  75. #
  76. #
  77. # ServerAdmin: Your address, where problems with the server should be
  78. # e-mailed. This address appears on some server-generated pages, such
  79. # as error documents. e.g. admin@your-domain.com
  80. #
  81. ServerAdmin root@localhost
  82. #
  83. # ServerName gives the name and port that the server uses to identify itself.
  84. # This can often be determined automatically, but we recommend you specify
  85. # it explicitly to prevent problems during startup.
  86. #
  87. # If your host doesn't have a registered DNS name, enter its IP address here.
  88. #
  89. #ServerName www.example.com:80
  90. #
  91. # Deny access to the entirety of your server's filesystem. You must
  92. # explicitly permit access to web content directories in other
  93. # <Directory> blocks below.
  94. #
  95. <Directory />
  96. AllowOverride none
  97. Require all denied
  98. </Directory>
  99. #
  100. # Note that from this point forward you must specifically allow
  101. # particular features to be enabled - so if something's not working as
  102. # you might expect, make sure that you have specifically enabled it
  103. # below.
  104. #
  105. #
  106. # DocumentRoot: The directory out of which you will serve your
  107. # documents. By default, all requests are taken from this directory, but
  108. # symbolic links and aliases may be used to point to other locations.
  109. #
  110. DocumentRoot "{{ apache.wwwdir }}"
  111. #
  112. # Relax access to content within /var/www.
  113. #
  114. <Directory "/var/www">
  115. AllowOverride None
  116. # Allow open access:
  117. Require all granted
  118. </Directory>
  119. # Further relax access to the default document root:
  120. <Directory "{{ apache.wwwdir }}">
  121. #
  122. # Possible values for the Options directive are "None", "All",
  123. # or any combination of:
  124. # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
  125. #
  126. # Note that "MultiViews" must be named *explicitly* --- "Options All"
  127. # doesn't give it to you.
  128. #
  129. # The Options directive is both complicated and important. Please see
  130. # http://httpd.apache.org/docs/2.4/mod/core.html#options
  131. # for more information.
  132. #
  133. Options Indexes FollowSymLinks
  134. #
  135. # AllowOverride controls what directives may be placed in .htaccess files.
  136. # It can be "All", "None", or any combination of the keywords:
  137. # Options FileInfo AuthConfig Limit
  138. #
  139. AllowOverride None
  140. #
  141. # Controls who can get stuff from this server.
  142. #
  143. Require all granted
  144. </Directory>
  145. #
  146. # DirectoryIndex: sets the file that Apache will serve if a directory
  147. # is requested.
  148. #
  149. <IfModule dir_module>
  150. DirectoryIndex index.html
  151. </IfModule>
  152. #
  153. # The following lines prevent .htaccess and .htpasswd files from being
  154. # viewed by Web clients.
  155. #
  156. <Files ".ht*">
  157. Require all denied
  158. </Files>
  159. #
  160. # ErrorLog: The location of the error log file.
  161. # If you do not specify an ErrorLog directive within a <VirtualHost>
  162. # container, error messages relating to that virtual host will be
  163. # logged here. If you *do* define an error logfile for a <VirtualHost>
  164. # container, that host's errors will be logged there and not here.
  165. #
  166. ErrorLog "{{ apache.logdir }}/error_log"
  167. #
  168. # LogLevel: Control the number of messages logged to the error_log.
  169. # Possible values include: debug, info, notice, warn, error, crit,
  170. # alert, emerg.
  171. #
  172. LogLevel warn
  173. <IfModule log_config_module>
  174. #
  175. # The following directives define some format nicknames for use with
  176. # a CustomLog directive (see below).
  177. #
  178. LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
  179. LogFormat "%h %l %u %t \"%r\" %>s %b" common
  180. {%- for log_format in salt['pillar.get']('apache:log_formats', []) %}
  181. LogFormat {{ log_format }}
  182. {%- endfor %}
  183. <IfModule logio_module>
  184. # You need to enable mod_logio.c to use %I and %O
  185. LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
  186. </IfModule>
  187. #
  188. # The location and format of the access logfile (Common Logfile Format).
  189. # If you do not define any access logfiles within a <VirtualHost>
  190. # container, they will be logged here. Contrariwise, if you *do*
  191. # define per-<VirtualHost> access logfiles, transactions will be
  192. # logged therein and *not* in this file.
  193. #
  194. #CustomLog "logs/access_log" common
  195. #
  196. # If you prefer a logfile with access, agent, and referer information
  197. # (Combined Logfile Format) you can use the following directive.
  198. #
  199. CustomLog "{{ apache.logdir }}/access_log" combined
  200. </IfModule>
  201. <IfModule alias_module>
  202. #
  203. # Redirect: Allows you to tell clients about documents that used to
  204. # exist in your server's namespace, but do not anymore. The client
  205. # will make a new request for the document at its new location.
  206. # Example:
  207. # Redirect permanent /foo http://www.example.com/bar
  208. #
  209. # Alias: Maps web paths into filesystem paths and is used to
  210. # access content that does not live under the DocumentRoot.
  211. # Example:
  212. # Alias /webpath /full/filesystem/path
  213. #
  214. # If you include a trailing / on /webpath then the server will
  215. # require it to be present in the URL. You will also likely
  216. # need to provide a <Directory> section to allow access to
  217. # the filesystem path.
  218. #
  219. # ScriptAlias: This controls which directories contain server scripts.
  220. # ScriptAliases are essentially the same as Aliases, except that
  221. # documents in the target directory are treated as applications and
  222. # run by the server when requested rather than as documents sent to the
  223. # client. The same rules about trailing "/" apply to ScriptAlias
  224. # directives as to Alias.
  225. #
  226. ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
  227. </IfModule>
  228. #
  229. # "/var/www/cgi-bin" should be changed to whatever your ScriptAliased
  230. # CGI directory exists, if you have that configured.
  231. #
  232. <Directory "/var/www/cgi-bin">
  233. AllowOverride None
  234. Options None
  235. Require all granted
  236. </Directory>
  237. <IfModule mime_module>
  238. #
  239. # TypesConfig points to the file containing the list of mappings from
  240. # filename extension to MIME-type.
  241. #
  242. TypesConfig /etc/mime.types
  243. #
  244. # AddType allows you to add to or override the MIME configuration
  245. # file specified in TypesConfig for specific file types.
  246. #
  247. #AddType application/x-gzip .tgz
  248. #
  249. # AddEncoding allows you to have certain browsers uncompress
  250. # information on the fly. Note: Not all browsers support this.
  251. #
  252. #AddEncoding x-compress .Z
  253. #AddEncoding x-gzip .gz .tgz
  254. #
  255. # If the AddEncoding directives above are commented-out, then you
  256. # probably should define those extensions to indicate media types:
  257. #
  258. AddType application/x-compress .Z
  259. AddType application/x-gzip .gz .tgz
  260. #
  261. # AddHandler allows you to map certain file extensions to "handlers":
  262. # actions unrelated to filetype. These can be either built into the server
  263. # or added with the Action directive (see below)
  264. #
  265. # To use CGI scripts outside of ScriptAliased directories:
  266. # (You will also need to add "ExecCGI" to the "Options" directive.)
  267. #
  268. #AddHandler cgi-script .cgi
  269. # For type maps (negotiated resources):
  270. #AddHandler type-map var
  271. #
  272. # Filters allow you to process content before it is sent to the client.
  273. #
  274. # To parse .shtml files for server-side includes (SSI):
  275. # (You will also need to add "Includes" to the "Options" directive.)
  276. #
  277. AddType text/html .shtml
  278. AddOutputFilter INCLUDES .shtml
  279. </IfModule>
  280. #
  281. # Specify a default charset for all content served; this enables
  282. # interpretation of all content as UTF-8 by default. To use the
  283. # default browser choice (ISO-8859-1), or to allow the META tags
  284. # in HTML content to override this choice, comment out this
  285. # directive:
  286. #
  287. AddDefaultCharset UTF-8
  288. <IfModule mime_magic_module>
  289. #
  290. # The mod_mime_magic module allows the server to use various hints from the
  291. # contents of the file itself to determine its type. The MIMEMagicFile
  292. # directive tells the module where the hint definitions are located.
  293. #
  294. MIMEMagicFile conf/magic
  295. </IfModule>
  296. #
  297. # Customizable error responses come in three flavors:
  298. # 1) plain text 2) local redirects 3) external redirects
  299. #
  300. # Some examples:
  301. #ErrorDocument 500 "The server made a boo boo."
  302. #ErrorDocument 404 /missing.html
  303. #ErrorDocument 404 "/cgi-bin/missing_handler.pl"
  304. #ErrorDocument 402 http://www.example.com/subscription_info.html
  305. #
  306. #
  307. # EnableMMAP and EnableSendfile: On systems that support it,
  308. # memory-mapping or the sendfile syscall may be used to deliver
  309. # files. This usually improves server performance, but must
  310. # be turned off when serving from networked-mounted
  311. # filesystems or if support for these functions is otherwise
  312. # broken on your system.
  313. # Defaults if commented: EnableMMAP On, EnableSendfile Off
  314. #
  315. #EnableMMAP off
  316. EnableSendfile on
  317. {%- for directive, dvalue in salt['pillar.get']('apache:global', {}).items() %}
  318. {{ directive }} {{ dvalue }}
  319. {%- endfor %}
  320. # Supplemental configuration
  321. #
  322. # Load config files in the "/etc/httpd/conf.d" directory, if any.
  323. IncludeOptional {{ apache.confdir }}/*.conf
  324. {% if apache.vhostdir != apache.confdir %}
  325. IncludeOptional {{ apache.vhostdir }}/*.conf
  326. {% endif %}