Giter Club home page Giter Club logo

apache2.4's Introduction

Apache2.4 configuration and templates

Apache2.4 personnal configuration and website templates on Debian linux distribution.

Note: I use those templates for my own projects, they contain the features I need.

Table of Contents

Requirements | Configuration | Templates | Documentation | Contributing | License

Requirements

  • Debian linux distribution: ~9.1
  • apache: ~2.4.25
    • Modules: alias, deflate, dir, env, evasive, expires, filter, headers, http2, include, rewrite, unique_id, ssl_module, proxy_module, proxy_http_module / proxy_http2_module, remoteip_module
  • openssl: ~1.1.0f

Configuration

I do not modify any Apache2.4 configuration files. I just add new configuration files to override the default Apache2.4 configuration.

When it starts, Apache2.4 includes the module configuration files (/etc/apache2/mods-enabled/*) and, then, the particular configuration snippets (/etc/apache2/conf-enabled/*.conf) which manage global configuration fragments.

Files

  • zzz-apache2.conf: overrides the main Apache server configuration.
  • zzz-deflate.conf: overrides the DEFLATE configuration that allows output from your server to be compressed before being sent to the client over the network.
  • zzz-dir.conf: overrides the default serving directory index files configuration.
  • zzz-evasive.conf: overrides the default EVASIVE module configuration.
  • zzz-expires.conf: overrides and extends the default expirations time by type.
  • zzz-expires-cdn.conf: modern version for caching while using CDN.
  • zzz-expires-fingerprint.conf: modern version for caching while using fingerprinted URLs.
  • zzz-headers.conf: adds few HTTP request and response headers customizations.
  • zzz-log.conf: overrides log configuration.
  • zzz-mime.conf: adds more mime types.
  • zzz-mpm_event.conf: overrides the event worker MPM default configuration.
  • zzz-php7.x-fpm.conf: configure the local php-fpm using proxy.
  • zzz-proxy.conf: overrides the multi-protocol proxy/gateway server default configuration.
  • zzz-remoteip.conf: overides remoteip configuration.
  • zzz-security.conf: overrides and adds more security configuration snippets for the server.
  • zzz-ssl.conf: SSL configuration.
  • zzz-status.conf: overrides the status and info modules configurations.

How to setup the Apache2.4 personnal configuration

  1. Copy the configuration files into /etc/apache2/conf-available
  2. Edit the named like zzz-***.conf files and make changes as you need.
  3. Enable the configuration you need using a2enconf zzz-***
  4. Test the configuration using apache2ctl -t
  5. When test is OK, activate the new configuration using systemctl reload apache2

Templates

I wrote theses templates to ease the process of creating named-based virtualhosts.

I do not use the module mod_macro, I only use the built-in Include and Define directives.

Each domain.tld directory contains configuration for HTTP and HTTPS. The domain.tld/include contains the common snippets for HTTP and HTTPS.

The Content Security Policy (CSP) snippets depends on your site and must be tested.

Module mod_http2 must be enable to provides HTTP/2 support in SSL.

Features

  • _common.conf: contains many files with common snippets.
    • access_control directory contains Access control directives for application and static website.
    • security directory contains security directives for HSTS and WordPress.
  • 000-default: contains the default virtualhost configuration.
  • static.tld: contains the name-based vhost configuration for a static website.
  • app.tld: contains the name-based vhost configuration for a PHP application.
  • api.tld: contains the name-based vhost configuration for a mixed static website and PHP application.
  • redirect.tld: contains the configuration for a redirection.
  • reverseproxy.tld: configuration sample for a reverse proxy.
    • remoteip_module, proxy_module and proxy_http_module or/and proxy_http2_module are required.
    • conf-available/zzz-expires.conf and conf-available/zzz-headers.conf should not be enabled.
  • loader.conf: one file to rule them all.

How to setup the site templates

  1. Copy the templates into /etc/apache2/sites-available
  2. Edit the files and make changes as you need.
  3. Edit and update the loader.conf file.
  4. Enable the sites using a2ensite loader
  5. restarts the Apache daemon using apache2ctl graceful

Documentation

I wrote and I use this package for my own projects. And, unfortunately, I do not provide exhaustive documentation. Please read the code and the comments ;)

For instructions on how to use, best practices, templates and other usage information, please visit the Apache2.4 documentation.

Contributing

Thanks you for taking the time to contribute. Please fork the repository and make changes as you'd like.

As I use these configuration and templates for my own projects, it contains only the features I need. But If you have any ideas, just open an issue and tell me what you think. Pull requests are also warmly welcome.

If you encounter any bugs in the configuration or templates, please open an issue.

Be sure to include a title and clear description,as much relevant information as possible, and a code sample or an executable test case demonstrating the expected behavior that is not occurring.

License

Apache2.4 configuration and templates are open-source and are licensed under the Apache-2.0 License.

apache2.4's People

Contributors

ojullien avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

apache2.4's Issues

HSTS preloading should be Opt-In

do not include the preload directive by default.

The preload directive will have long-term consequences. If the HTTPS configuration is wrong, broken or we don't want to use HTTPS anymore, we will experience problems.

Add HTTP Permissions-Policy header

The HTTP Permissions-Policy header provides a mechanism to allow and deny the use of browser features in its own frame, and in content within any <iframe> elements in the document.

Read the MDN's article

mime type: application/x-httpd-php

In reverse proxy case, the result of a parsed php file is served as application/x-httpd-php (and so downloadable) instead of text/html.

in the zzz-mime.conf the line AddType application/x-httpd-php .php .phtml must be commented.
This line is useful for mod_php and not php-fpm (as we use mod_proxy_fcgi)

Configure Etag

Use ETag header to help you revalidate expired cache resources more efficiently.

HSTS preload directives are not valid.

Bugs

  • The max-age must be at least 31536000 seconds (โ‰ˆ 1 year), but the header currently only has max-age=15768000.

  • HTTP redirects to www first http://app.tld (HTTP) should immediately redirect to https://app.tld (HTTPS) before adding the www subdomain. Right now, the first redirect is to https://www.app.tld/. The extra redirect is required to ensure that any browser which supports HSTS will record the HSTS entry for the top level domain, not just the subdomain.

Information

In order to be accepted to the HSTS preload list, the site must satisfy the following set of requirements:

  • Serve a valid certificate.
  • Redirect from HTTP to HTTPS on the same host, if you are listening on port 80.
  • Serve all subdomains over HTTPS.
    • In particular, you must support HTTPS for the www subdomain if a DNS record for that subdomain exists.
  • Serve an HSTS header on the base domain for HTTPS requests:
    • The max-age must be at least 31536000 seconds (1 year).
    • The includeSubDomains directive must be specified.
    • The preload directive must be specified.
    • If you are serving an additional redirect from your HTTPS site, that redirect must still have the HSTS header (rather than the page it redirects to).

Remove unneeded HTTP CSP Header

HTTP Content Security Policy header does not make sense to be sent for many static files,, as sending them does not provide any value to users and contributes to header bloat.

Reverse proxy case: duplicate headers.

If the server is a reverse proxy and to avoid duplicates headers: do not load the conf-available/zzz-expires.conf and conf-available/zzz-headers.conf

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.