apache-server-configs
Advanced tools
Comparing version 2.15.0 to 3.0.0
@@ -0,1 +1,17 @@ | ||
### 3.0.0 (April 16, 2018) | ||
* ⚠️ **Breaking**: End of support for Apache httpd version 2.3 and below | ||
[[7d296c3](https://github.com/h5bp/server-configs-apache/commit/7d296c35c7337ca183bd31326e10e15d54ca187b)] | ||
* 🎉 New build system! Configurable build and customizable generation. See the [README](https://github.com/h5bp/server-configs-apache#custom-htaccess-builds) | ||
[[5896349](https://github.com/h5bp/server-configs-apache/commit/589634974291a4a9ee1fd2a99c23794036e9aace)] | ||
* Add Referrer-Policy header template | ||
[[591083e](https://github.com/h5bp/server-configs-apache/commit/591083eedc654837c051ca1aff4282444dc06471)] | ||
* Switch back `.js`-files and `.mjs`-files media-type to `text/javascript` | ||
[[690f4ad](https://github.com/h5bp/server-configs-apache/commit/690f4ad6add3a3c2185641474e05378000a19d84)] | ||
* Add pre-compressed content handling template | ||
[[52639ab](https://github.com/h5bp/server-configs-apache/commit/52639ab1fa97d666f3b262e04f70ab3ce020d0d0)] | ||
* Add WebAssembly module (`.wasm`) MIME type | ||
[[a2e7d7b](https://github.com/h5bp/server-configs-apache/commit/a2e7d7b38cf96b804a7323362ee72950e51810f5)] | ||
* Improve inline comments. | ||
### 2.15.0 (October 8, 2017) | ||
@@ -2,0 +18,0 @@ |
{ | ||
"author": "The H5BP Team", | ||
"description": "Boilerplate configurations for the Apache HTTP server", | ||
"version": "2.15.0", | ||
"homepage": "https://github.com/h5bp/server-configs-apache", | ||
"license": "MIT", | ||
"name": "apache-server-configs", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/h5bp/server-configs-apache.git" | ||
"devDependencies": { | ||
"@alrra/travis-scripts": "^3.0.1", | ||
"eslint": "^4.19.1", | ||
"mocha": "^5.1.0" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/h5bp/server-configs-apache/issues" | ||
"eslintConfig": { | ||
"root": true, | ||
"env": { | ||
"node": true, | ||
"mocha": true | ||
}, | ||
"extends": "eslint:recommended" | ||
}, | ||
"eslintIgnore": [ | ||
"test/fixtures/**" | ||
], | ||
"files": [ | ||
"dist" | ||
], | ||
"homepage": "https://github.com/h5bp/server-configs-apache", | ||
"keywords": [ | ||
@@ -24,18 +33,15 @@ "apache", | ||
], | ||
"license": "MIT", | ||
"name": "apache-server-configs", | ||
"repository": "h5bp/server-configs-apache", | ||
"scripts": { | ||
"build": "bin/build/build.sh", | ||
"eslint": "eslint \"**/*.js\"", | ||
"lint": "npm run eslint", | ||
"build": "bin/build.sh", | ||
"build:dist": "npm run build -- dist/.htaccess htaccess.conf", | ||
"build:test": "npm run build -- test/fixtures/.htaccess test/htaccess_fixture.conf", | ||
"build:user": "test/test_userbuild.sh", | ||
"lint": "eslint \"**/*.js\"", | ||
"mocha": "mocha --reporter spec --timeout 5000 test/test_suite.js", | ||
"test": "npm run eslint && npm run build && npm run mocha" | ||
"test": "npm run lint && npm run build:test && npm run build:user && npm run mocha" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"@alrra/travis-scripts": "^3.0.1", | ||
"eslint": "^4.8.0", | ||
"mocha": "^4.0.1" | ||
}, | ||
"files": [ | ||
"dist" | ||
] | ||
"version": "3.0.0" | ||
} |
147
README.md
@@ -16,7 +16,9 @@ # [Apache Server Configs](https://github.com/h5bp/server-configs-apache/) | ||
* Download the [zip archive](https://github.com/h5bp/server-configs-apache/archive/2.15.0.zip) | ||
* Install them via [npm](https://www.npmjs.com/): | ||
* Download the [zip archive](https://github.com/h5bp/server-configs-apache/archive/3.0.0.zip) | ||
* Install them via [npm](https://www.npmjs.com/): | ||
`npm install --save-dev apache-server-configs` | ||
Inside the **dist/** folder, you'll find a ready-to-use **.htaccess** file. | ||
## Usage | ||
@@ -26,4 +28,4 @@ | ||
file](https://httpd.apache.org/docs/current/configuring.html#main) | ||
(usually called `httpd.conf`), you should add the logic from the | ||
[`.htaccess`](https://github.com/h5bp/server-configs-apache/blob/master/dist/.htaccess) | ||
(usually called `httpd.conf`), you should add the logic from the pre-built | ||
[`dist/.htaccess`](https://github.com/h5bp/server-configs-apache/blob/master/dist/.htaccess) | ||
file in, for example, a | ||
@@ -43,3 +45,3 @@ [`<Directory>`](https://httpd.apache.org/docs/current/mod/core.html#directory) | ||
to work as intended, you need to ensure the you have the following | ||
Apache modules [enabled](https://github.com/h5bp/server-configs-apache/wiki/How-to-enable-Apache-modules): | ||
Apache modules enabled: | ||
@@ -62,5 +64,138 @@ * [`mod_autoindex.c` (autoindex_module)](https://httpd.apache.org/docs/current/mod/mod_autoindex.html) | ||
### Enable Apache httpd modules | ||
#### Standalone | ||
These instructions should work on any distribution where `apt-get` has been | ||
used to install Apache. | ||
1. Open up a terminal and type the following command. Enter your password when | ||
prompted. | ||
`sudo a2enmod setenvif headers deflate filter expires rewrite include` | ||
2. Restart apache by using the following command so the new configuration takes | ||
effect. | ||
`sudo /etc/init.d/apache2 restart` | ||
#### With MAMP/WAMP/XAMPP | ||
* **MAMP PRO**. On the main screen, click the `Apache` tab and ensure that all | ||
the required modules are 'checked', indicating they are enabled. | ||
* **WampServer**. If you have installed WampServer just click on the icon in the | ||
task bar then <kbd>Apache</kbd> section then <kbd>modules</kbd> section. | ||
You will be presented with a list of modules. Simply click on a module name | ||
to enable it. WampServer will automatically restart the Apache service after | ||
you enable a module. | ||
* **Others**. Locate the `httpd.conf` file, which is typically found in: | ||
* **MAMP**: `/Applications/MAMP/conf/apache/httpd.conf` | ||
* **XAMPP**: `/Applications/XAMPP/etc/httpd.conf` | ||
* **WAMP**: `C:\apache\conf\httpd.conf` | ||
Open the file in a text editor and uncomment all of the required modules. | ||
Once you have done so, reset MAMP/WAMP/XAMPP. | ||
## Custom .htaccess builds | ||
Security, mime-type, and caching best practices evolve, and so should do your *.htaccess* file. In the past, with each new *Apache Server Configs* release it was quite tedious to find out which *.htaccess* trick was just new or only had changes in certain nuances. | ||
The [**build script**](#build-script-buildsh) with its re-usable and customizable [**build configuration**](#configuration-file-htaccessconf) lets you easily update your *.htaccess* file. Each new *.htaccess* build will contain the updated *Apache Server Configs* source files, enabled or commented-out according to your settings in the *htaccess.conf* of your project root. | ||
### Configuration file: *htaccess.conf* | ||
Allows you to define which module to [enable](#enabling-modules) or [disable](#disabling-modules) for your project. Just copy the default [**htaccess.conf**](https://github.com/h5bp/server-configs-apache/blob/master/htaccess.conf) from this repo into your project directory. Adjust to your needs, and/or [add custom code](#adding-custom-modules) snippets you need for your project. Its syntax is straight and pretty much self-explanatory: | ||
``` | ||
# Example Module | ||
title "example module" | ||
enable "src/example-module/images.conf" | ||
enable "src/example-module/web_fonts.conf" | ||
disable "src/example-module/not-needed.conf" | ||
omit "src/example-module/not-needed-at-all.conf" | ||
... more modules ... | ||
``` | ||
#### Disabling modules | ||
For example, the *“Cross-origin web fonts”* snippet is always included in our pre-built [*.htaccess*](https://github.com/h5bp/server-configs-apache/blob/master/dist/.htaccess) file and enabled. If your project does not deal with web fonts, you can **disable** or **omit** this section: | ||
This will comment out the section: | ||
``` | ||
disable "src/cross-origin/web_fonts.conf" | ||
``` | ||
…and this will exclude the section, saving lines in output: | ||
``` | ||
omit "src/cross-origin/web_fonts.conf" | ||
``` | ||
#### Enabling modules | ||
For example, the *“Forcing https://”* snippet is disabled by default, although being included in our pre-built [*.htaccess*](https://github.com/h5bp/server-configs-apache/blob/master/dist/.htaccess). To enable this snippet, change the **disable** keyword to **enable:** | ||
``` | ||
enable "src/rewrites/rewrite_http_to_https.conf" | ||
``` | ||
#### Adding custom modules | ||
Imagine you're passing all requests to non-existing files to your favourite web framework. The according *mod_rewrite* snippet would go like this: | ||
``` | ||
RewriteEngine On | ||
RewriteCond %{REQUEST_FILENAME} !-f | ||
RewriteCond %{REQUEST_FILENAME} !-d | ||
RewriteRule ^ index.php [QSA,L] | ||
``` | ||
Store this snippet in a file, e.g. **config/framework_rewrites.conf,** and add a reference in your **htaccess.conf:** | ||
``` | ||
# PROJECT MODULES | ||
enable "config/framework_rewrites.conf" | ||
``` | ||
### Build script: *build.sh* | ||
Dive into your project root and call the build script from wherever you cloned the repo. Here are three examples: | ||
**1. Create a default .htaccess** | ||
in current work directory. An existing **htaccess.conf** in this directory will be used; if none is present, the [**default configuration**](https://github.com/h5bp/server-configs-apache/blob/master/htaccess.conf) will apply. | ||
```bash | ||
$ path/to/server-configs-apache/bin/build.sh | ||
# Output looks like: | ||
[✔] Build .htaccess | ||
[✔] Moved in place: './.htaccess' | ||
``` | ||
**2. Custom output location** | ||
Just add output path and filename as parameter. By the way, if there's an existing *.htaccess* file, the build script will create a backup. | ||
```bash | ||
$ path/to/server-configs-apache/bin/build.sh htdocs/.htaccess | ||
[✔] Build .htaccess | ||
[✔] Create backup: 'htdocs/.htaccess~' | ||
[✔] Moved in place: 'htdocs/.htaccess' | ||
``` | ||
**3. Custom .htaccess configuration** | ||
Why not maintain your personal **~/htaccess.conf?** This example creates a *.htaccess* in current work directory, according to your favourite settings you may have stored in your `$HOME` directory: | ||
```bash | ||
$ path/to/server-configs-apache/bin/build.sh ./.htaccess ~/htaccess.conf | ||
``` | ||
## Support | ||
* ### __Apache v2.2.0+__ | ||
* ### __Apache v2.4.0+__ | ||
* ### __Browsers:__ | ||
@@ -67,0 +202,0 @@ * Chrome |
Sorry, the diff of this file is not supported yet
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
69827
222
1
1
1