Saltstack Official Apache Formula
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

394 行
13KB

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