<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Flaxe</id>
	<title>Alpine Linux - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.alpinelinux.org/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Flaxe"/>
	<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/wiki/Special:Contributions/Flaxe"/>
	<updated>2026-04-30T13:50:21Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.40.0</generator>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=19604</id>
		<title>Nginx as reverse proxy with acme (letsencrypt)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=19604"/>
		<updated>2021-06-16T18:37:55Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This setup will allow you to have multiple servers/containers accessible via a single IP address with the added benefit of a centralized generation of [https://letsencrypt.org/ letsencrypt] certificates and secure https (according to &#039;&#039;&#039;ssllabs ssltest&#039;&#039;&#039;). Be aware that you first need to setup a regular HTTP server in order to be able to generate your HTTPS certificates and keys. After you have generated them, you can then add your HTTPS host based configuration.&lt;br /&gt;
&lt;br /&gt;
See the [[Nginx|NGINX]] page for general information about Nginx, starting/stopping the service etc.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
For this howto, we need three tools: [[Nginx|NGINX]], {{pkg|acme-client}} and {{pkg|openssl}} (to generate [https://wiki.openssl.org/index.php/Diffie-Hellman_parameters Diffie–Hellman Parameters]).&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk update&lt;br /&gt;
apk add nginx acme-client openssl}}&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTP ===&lt;br /&gt;
&lt;br /&gt;
==== Global configuration ====&lt;br /&gt;
&lt;br /&gt;
First step is to refactor our global &amp;lt;code&amp;gt;nginx.conf&amp;lt;/code&amp;gt;. Its target at a low traffic http server, to increase performance make changes at top level.&lt;br /&gt;
{{Cat|/etc/nginx/nginx.conf|&amp;lt;nowiki&amp;gt;# /etc/nginx/nginx.conf&lt;br /&gt;
&lt;br /&gt;
user nginx;&lt;br /&gt;
worker_processes 1; # use &amp;quot;auto&amp;quot; to use all available cores (high performance)&lt;br /&gt;
&lt;br /&gt;
# Configures default error logger.&lt;br /&gt;
error_log /var/log/nginx/error.log warn; # Log warn, error, crit, alert, emerg&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    # The maximum number of simultaneous connections that can be opened by a worker process.&lt;br /&gt;
    worker_connections 1024; # increase if you need more connections&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    # server_names_hash_bucket_size controls the maximum length&lt;br /&gt;
    # of a virtual host entry (ie the length of the domain name).&lt;br /&gt;
    server_names_hash_bucket_size   64; # controls the maximum length of a virtual host entry (ie domain name)&lt;br /&gt;
    server_tokens                   off; # hide who we are, don&#039;t show nginx version to clients&lt;br /&gt;
    sendfile                        off; # can cause issues&lt;br /&gt;
&lt;br /&gt;
    # nginx will find this file in the config directory set at nginx build time&lt;br /&gt;
    # Includes mapping of file name extensions to MIME types of responses&lt;br /&gt;
    include mime.types;&lt;br /&gt;
&lt;br /&gt;
    # fallback in case we can&#039;t determine a type&lt;br /&gt;
    default_type application/octet-stream;&lt;br /&gt;
&lt;br /&gt;
    # buffering causes issues, disable it&lt;br /&gt;
    # increase buffer size. still useful even when buffering is off&lt;br /&gt;
    proxy_buffering off;&lt;br /&gt;
    proxy_buffer_size 4k;&lt;br /&gt;
&lt;br /&gt;
    # allow the server to close the connection after a client stops responding. Frees up socket-associated memory.&lt;br /&gt;
    reset_timedout_connection on;&lt;br /&gt;
&lt;br /&gt;
    # Specifies the main log format.&lt;br /&gt;
    log_format main &#039;$remote_addr - $remote_user [$time_local] &amp;quot;$request&amp;quot; &#039;&lt;br /&gt;
            &#039;$status $body_bytes_sent &amp;quot;$http_referer&amp;quot; &#039;&lt;br /&gt;
            &#039;&amp;quot;$http_user_agent&amp;quot; &amp;quot;$http_x_forwarded_for&amp;quot;&#039;;&lt;br /&gt;
&lt;br /&gt;
    # Sets the path, format, and configuration for a buffered log write.&lt;br /&gt;
    # Buffer log writes to speed up IO, or disable them altogether&lt;br /&gt;
    access_log /var/log/nginx/access.log main buffer=16k;&lt;br /&gt;
    #access_log off;&lt;br /&gt;
&lt;br /&gt;
    # include virtual hosts configs&lt;br /&gt;
    include conf.d/*.conf;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== SSL configuration ====&lt;br /&gt;
&lt;br /&gt;
Configure a file with all SSL-parameters that we can include in the virtual hosts configs later on.&amp;lt;br&amp;gt;&lt;br /&gt;
The security settings are taken from https://cipherli.st. Please also read https://hstspreload.org for details about HSTS.&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/ssl-params.inc|&amp;lt;nowiki&amp;gt;# secure nginx, see https://cipherli.st/&lt;br /&gt;
&lt;br /&gt;
#ssl_protocols TLSv1.3; # Requires nginx &amp;gt;= 1.13.0 else use TLSv1.2&lt;br /&gt;
ssl_protocols TLSv1.2; # We use TLSv1.2 because current stable nginx release don&#039;t support TLSv1.3 yet&lt;br /&gt;
ssl_prefer_server_ciphers on;&lt;br /&gt;
ssl_dhparam /etc/nginx/dhparam.pem; # openssl dhparam -out /etc/nginx/dhparam.pem 4096&lt;br /&gt;
ssl_ciphers &amp;quot;EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH&amp;quot;;&lt;br /&gt;
ssl_ecdh_curve secp384r1; # Requires nginx &amp;gt;= 1.1.0&lt;br /&gt;
ssl_session_cache shared:SSL:10m;&lt;br /&gt;
ssl_session_tickets off; # Requires nginx &amp;gt;= 1.5.9&lt;br /&gt;
ssl_stapling on; # Requires nginx &amp;gt;= 1.3.7&lt;br /&gt;
ssl_stapling_verify on; # Requires nginx =&amp;gt; 1.3.7&lt;br /&gt;
resolver 8.8.8.8 8.8.4.4 valid=300s;&lt;br /&gt;
resolver_timeout 5s;&lt;br /&gt;
&lt;br /&gt;
# https://hstspreload.org&lt;br /&gt;
add_header Strict-Transport-Security &amp;quot;max-age=63072000&amp;quot; always; &lt;br /&gt;
# By default, HSTS header is not added to subdomain requests. If you have subdomains and want&lt;br /&gt;
# HSTS to apply to all of them, you should add the includeSubDomains variable like this:&lt;br /&gt;
#add_header Strict-Transport-Security &amp;quot;max-age=63072000; includeSubDomains&amp;quot; always;&lt;br /&gt;
&lt;br /&gt;
add_header X-Frame-Options DENY;&lt;br /&gt;
add_header X-Content-Type-Options nosniff;&lt;br /&gt;
add_header X-XSS-Protection &amp;quot;1; mode=block&amp;quot;;&lt;br /&gt;
add_header X-Robots-Tag none;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Diffie–Hellman Parameters ====&lt;br /&gt;
&lt;br /&gt;
In the above configuration &amp;lt;var&amp;gt;ssl_dhparam&amp;lt;/var&amp;gt; is used, so we need to generate a global &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file. We want to use a 4096 key size, but this can take a very long time. Because of this, we are adding an extra option (&amp;lt;var&amp;gt;dsaparam&amp;lt;/var&amp;gt;) to generate our &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file (see [https://wiki.openssl.org/index.php/Manual:Dhparam(1)#OPTIONS this] wiki section):&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096}}&lt;br /&gt;
&lt;br /&gt;
At this point, you should be able to (re)start your nginx server, but it will not use any of the security features yet.&lt;br /&gt;
&lt;br /&gt;
==== Per site configuration files (conf.d) ====&lt;br /&gt;
&lt;br /&gt;
Since Alpine v3.5, we ship &#039;&#039;&#039;NGINX&#039;&#039;&#039; with a &amp;lt;code&amp;gt;default.conf&amp;lt;/code&amp;gt; within the {{path|/etc/nginx/conf.d}} directory.&lt;br /&gt;
&lt;br /&gt;
To add support for another website, you can add files with the &#039;&#039;&#039;.conf&#039;&#039;&#039; extension to this directory:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Common configuration includes ====&lt;br /&gt;
&lt;br /&gt;
If you need to setup multiple proxy setups, you can include duplicated data such as shown below:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/proxy_set_header.inc|&amp;lt;nowiki&amp;gt;proxy_set_header    X-Forwarded-By       $server_addr:$server_port;&lt;br /&gt;
proxy_set_header    X-Forwarded-For      $remote_addr;&lt;br /&gt;
proxy_set_header    X-Forwarded-Proto    $scheme;&lt;br /&gt;
proxy_set_header    Host                 $host;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== acme-client ===&lt;br /&gt;
To allow &#039;&#039;&#039;NGINX&#039;&#039;&#039; to support https, we need to add certificates and support for ACME (Automatic Certificate Management Environment) responses.&lt;br /&gt;
&lt;br /&gt;
==== ACME responses ====&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/acme.inc|&amp;lt;nowiki&amp;gt;# Allow access to the ACME Challenge for Let&#039;s Encrypt&lt;br /&gt;
location ^~ /.well-known/acme-challenge {&lt;br /&gt;
    allow all;&lt;br /&gt;
    alias /var/www/acme;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
And add this to your proxy configuration:&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Automatic generation of certificates ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
{{Cat|/etc/periodic/weekly/acme-client|&amp;lt;nowiki&amp;gt;#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for host in $hosts; do&lt;br /&gt;
        acme-client -a https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf -Nnmv $host &amp;amp;&amp;amp; renew=1&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
[ &amp;quot;$renew&amp;quot; = 1 ] &amp;amp;&amp;amp; rc-service nginx reload&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Make it executable:&lt;br /&gt;
 chmod +x /etc/periodic/weekly/acme-client&lt;br /&gt;
&lt;br /&gt;
This script will run weekly to verify whether one of your certificates is outdated and renew them when needed.&lt;br /&gt;
&lt;br /&gt;
If you have several domains, you can add them to the &#039;&#039;&#039;hosts=&#039;&#039;&#039; variable with a space between each domain. This will create a separate certificate and key for each:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org example.com foo.org bar.io&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Initial generation of keys and certificates ====&lt;br /&gt;
&lt;br /&gt;
To create your initial certificates and keys, you have to run this manually the first time:&lt;br /&gt;
&lt;br /&gt;
 {{Cmd|/etc/periodic/weekly/acme-client}}&lt;br /&gt;
&lt;br /&gt;
Watch the output and see if all goes well. When it&#039;s finished, you should have files in:&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/alpinelinux.nl/fullchain.pem&lt;br /&gt;
 /etc/ssl/acme/private/alpinelinux.org/privkey.pem&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Per site HTTPS configuration ====&lt;br /&gt;
&lt;br /&gt;
Add the following below the previous HTTP configuration:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl http2;&lt;br /&gt;
    server_name             alpinelinux.org&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    include /etc/nginx/conf.d/ssl-params.inc; # SSL parameters&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Redirect HTTP to HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Shared configuration ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/redirect_http.inc|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
location / {&lt;br /&gt;
        return 301 https://$host$request_uri;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Update host configuration ====&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
    include       conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Complete host example with IPv6 support ===&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  80;&lt;br /&gt;
    listen                  [::]:80;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    include                 conf.d/acme.inc;&lt;br /&gt;
    include                 conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl http2;&lt;br /&gt;
    listen                  [::]:443 ssl http2;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    include /etc/nginx/conf.d/ssl-params.inc; # SSL parameters&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx&amp;diff=14207</id>
		<title>Nginx</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx&amp;diff=14207"/>
		<updated>2017-12-10T17:26:27Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* Troubleshooting */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://nginx.org/en/ Nginx] (engine x) is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP/UDP proxy server&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
Nginx package is available in the Alpine Linux repositories. To install it run:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk update&lt;br /&gt;
apk add nginx}}&lt;br /&gt;
&lt;br /&gt;
Creating new user and group &#039;www&#039; for nginx&lt;br /&gt;
{{Cmd|adduser -D -g &#039;www&#039; www}}&lt;br /&gt;
&lt;br /&gt;
Create a directory for html files&lt;br /&gt;
{{Cmd|mkdir /www&lt;br /&gt;
chown -R www:www /var/lib/nginx&lt;br /&gt;
chown -R www:www /www&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
You may want to make backup of original nginx.conf file before writting your own&lt;br /&gt;
{{Cmd|mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig}}&lt;br /&gt;
&lt;br /&gt;
Configuring Nginx to listen to port 80 and process .html or .htm files&lt;br /&gt;
{{Cmd|vi /etc/nginx/nginx.conf}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
user                            www;&lt;br /&gt;
worker_processes                1;&lt;br /&gt;
&lt;br /&gt;
error_log                       /var/log/nginx/error.log warn;&lt;br /&gt;
pid                             /var/run/nginx.pid;&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections          1024;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    include                     /etc/nginx/mime.types;&lt;br /&gt;
    default_type                application/octet-stream;&lt;br /&gt;
    sendfile                    on;&lt;br /&gt;
    access_log                  /var/log/nginx/access.log;&lt;br /&gt;
    keepalive_timeout           3000;&lt;br /&gt;
    server {&lt;br /&gt;
        listen                  80;&lt;br /&gt;
        root                    /www;&lt;br /&gt;
        index                   index.html index.htm;&lt;br /&gt;
        server_name             localhost;&lt;br /&gt;
        client_max_body_size    32m;&lt;br /&gt;
        error_page              500 502 503 504  /50x.html;&lt;br /&gt;
        location = /50x.html {&lt;br /&gt;
              root              /var/lib/nginx/html;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample page ==&lt;br /&gt;
{{Cmd|vi /www/index.html}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html lang=&amp;quot;en&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;meta charset=&amp;quot;utf-8&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;title&amp;gt;HTML5&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
    Server is online&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Controlling nginx ==&lt;br /&gt;
&lt;br /&gt;
=== Test configuration ===&lt;br /&gt;
When you&#039;ve made any changes to your nginx configuration files, you should check it for errors before starting/restarting/reloading nginx.&amp;lt;br&amp;gt;&lt;br /&gt;
This will check for any duplicate configuration, syntax errors etc. To do this, run:&lt;br /&gt;
{{Cmd|nginx -t}}&lt;br /&gt;
&lt;br /&gt;
You will get a feedback if it failed or not. If everything is fine, you&#039;ll see the following and can then move ahead to start the nginx server.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok&lt;br /&gt;
nginx: configuration file /etc/nginx/nginx.conf test is successful&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Start Nginx ===&lt;br /&gt;
After the installation Nginx is not running. To start Nginx, use &#039;&#039;start&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx start}}&lt;br /&gt;
&lt;br /&gt;
You will get a feedback about the status.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 * /run/nginx: creating directory&lt;br /&gt;
 * /run/nginx: correcting owner                         [ ok ]&lt;br /&gt;
 * Starting nginx ...                                   [ ok ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reload and Restart Nginx ===&lt;br /&gt;
Changes made in the configuration file will not be applied until the command to reload configuration is sent to nginx or it is restarted.&amp;lt;br&amp;gt;&lt;br /&gt;
Reloading will do a &amp;quot;hot reload&amp;quot; of the configuration without server downtime. It will start the new worker processes with a new configuration and gracefully shutdown the old worker processes. If you have pending requests, then these will be handled by the old worker processes before it dies, so it&#039;s an extremely graceful way to reload configs.&lt;br /&gt;
If you want to reload the web server, use &#039;&#039;reload&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx reload}}&lt;br /&gt;
If you want to restart the web server, use &#039;&#039;restart&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx restart}}&lt;br /&gt;
&lt;br /&gt;
=== Stop Nginx ===&lt;br /&gt;
If you want to stop the web server, use &#039;&#039;stop&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx stop}}&lt;br /&gt;
&lt;br /&gt;
=== Runlevel ===&lt;br /&gt;
Normally you want to start the web server when the system is launching. This is done by adding Nginx to the needed runlevel.&lt;br /&gt;
{{Cmd|rc-update add nginx default}}&lt;br /&gt;
&lt;br /&gt;
Now Nginx should start automatically when you boot your machine next time. To test that run:&lt;br /&gt;
{{cmd|reboot}}&lt;br /&gt;
&lt;br /&gt;
To make sure that Nginx is started run:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;ps aux | grep nginx&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You should get something like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  263 root       0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf&lt;br /&gt;
  264 www        0:00 nginx: worker process&lt;br /&gt;
  310 root       0:00 grep nginx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Nginx ==&lt;br /&gt;
This section is assuming that nginx is running and sample html page &amp;quot;/www/index.html&amp;quot; is created. Launch a web browser and point it to your web server.&lt;br /&gt;
You should get:&lt;br /&gt;
&amp;lt;pre&amp;gt;Server is online&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
If Nginx is not started check Nginx log file&lt;br /&gt;
{{cmd|less /var/log/nginx/error.log}}&lt;br /&gt;
&lt;br /&gt;
Make sure that configuration file does not contain errors. Edit the file in case there are any errors.&lt;br /&gt;
{{cmd|nginx -t&lt;br /&gt;
vi /etc/nginx/nginx.conf}}&lt;br /&gt;
&lt;br /&gt;
== Nginx with PHP ==&lt;br /&gt;
&lt;br /&gt;
[[Nginx_with_PHP#Nginx_with_PHP|Setting Up Nginx with PHP]] &amp;lt;br&amp;gt;&lt;br /&gt;
[[Nginx_as_reverse_proxy_with_acme_(letsencrypt)|Setting Up Nginx as Reverse Proxy with acme (Let&#039;s Encrypt)]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14206</id>
		<title>Nginx as reverse proxy with acme (letsencrypt)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14206"/>
		<updated>2017-12-10T10:55:19Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This setup will allow you to have multiple servers/containers accessible via a single IP address with the added benefit of a centralized generation of [https://letsencrypt.org/ letsencrypt] certificates and secure https (according to &#039;&#039;&#039;ssllabs ssltest&#039;&#039;&#039;). Be aware that you first need to setup a regular HTTP server in order to be able to generate your HTTPS certificates and keys. After you have generated them, you can then add your HTTPS host based configuration.&lt;br /&gt;
&lt;br /&gt;
See the [[Nginx|NGINX]] page for general information about Nginx, starting/stopping the service etc.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
For this howto, we need three tools: [[Nginx|NGINX]], {{pkg|acme-client}} and {{pkg|libressl}} (to generate [https://wiki.openssl.org/index.php/Diffie-Hellman_parameters Diffie–Hellman Parameters]).&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk update&lt;br /&gt;
apk add nginx acme-client libressl}}&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTP ===&lt;br /&gt;
&lt;br /&gt;
==== Global configuration ====&lt;br /&gt;
&lt;br /&gt;
First step is to refactor our global &amp;lt;code&amp;gt;nginx.conf&amp;lt;/code&amp;gt;. Its target at a low traffic http server, to increase performance make changes at top level.&lt;br /&gt;
{{Cat|/etc/nginx/nginx.conf|&amp;lt;nowiki&amp;gt;# /etc/nginx/nginx.conf&lt;br /&gt;
&lt;br /&gt;
user nginx;&lt;br /&gt;
worker_processes 1; # use &amp;quot;auto&amp;quot; to use all available cores (high performance)&lt;br /&gt;
&lt;br /&gt;
# Configures default error logger.&lt;br /&gt;
error_log /var/log/nginx/error.log warn; # Log warn, error, crit, alert, emerg&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    # The maximum number of simultaneous connections that can be opened by a worker process.&lt;br /&gt;
    worker_connections 1024; # increase if you need more connections&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    # server_names_hash_bucket_size controls the maximum length&lt;br /&gt;
    # of a virtual host entry (ie the length of the domain name).&lt;br /&gt;
    server_names_hash_bucket_size   64; # controls the maximum length of a virtual host entry (ie domain name)&lt;br /&gt;
    server_tokens                   off; # hide who we are, don&#039;t show nginx version to clients&lt;br /&gt;
    sendfile                        off; # can cause issues&lt;br /&gt;
&lt;br /&gt;
    # nginx will find this file in the config directory set at nginx build time&lt;br /&gt;
    # Includes mapping of file name extensions to MIME types of responses&lt;br /&gt;
    include mime.types;&lt;br /&gt;
&lt;br /&gt;
    # fallback in case we can&#039;t determine a type&lt;br /&gt;
    default_type application/octet-stream;&lt;br /&gt;
&lt;br /&gt;
    # buffering causes issues, disable it&lt;br /&gt;
    # increase buffer size. still useful even when buffering is off&lt;br /&gt;
    proxy_buffering off;&lt;br /&gt;
    proxy_buffer_size 4k;&lt;br /&gt;
&lt;br /&gt;
    # allow the server to close the connection after a client stops responding. Frees up socket-associated memory.&lt;br /&gt;
    reset_timedout_connection on;&lt;br /&gt;
&lt;br /&gt;
    # Specifies the main log format.&lt;br /&gt;
    log_format main &#039;$remote_addr - $remote_user [$time_local] &amp;quot;$request&amp;quot; &#039;&lt;br /&gt;
            &#039;$status $body_bytes_sent &amp;quot;$http_referer&amp;quot; &#039;&lt;br /&gt;
            &#039;&amp;quot;$http_user_agent&amp;quot; &amp;quot;$http_x_forwarded_for&amp;quot;&#039;;&lt;br /&gt;
&lt;br /&gt;
    # Sets the path, format, and configuration for a buffered log write.&lt;br /&gt;
    # Buffer log writes to speed up IO, or disable them altogether&lt;br /&gt;
    access_log /var/log/nginx/access.log main buffer=16k;&lt;br /&gt;
    #access_log off;&lt;br /&gt;
&lt;br /&gt;
    # include virtual hosts configs&lt;br /&gt;
    include conf.d/*.conf;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== SSL configuration ====&lt;br /&gt;
&lt;br /&gt;
Configure a file with all SSL-parameters that we can include in the virtual hosts configs later on.&amp;lt;br&amp;gt;&lt;br /&gt;
The security settings are taken from https://cipherli.st. Please also read https://hstspreload.org for details about HSTS.&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/ssl-params.inc|&amp;lt;nowiki&amp;gt;# secure nginx, see https://cipherli.st/&lt;br /&gt;
&lt;br /&gt;
#ssl_protocols TLSv1.3; # Requires nginx &amp;gt;= 1.13.0 else use TLSv1.2&lt;br /&gt;
ssl_protocols TLSv1.2; # We use TLSv1.2 because current stable nginx release don&#039;t support TLSv1.3 yet&lt;br /&gt;
ssl_prefer_server_ciphers on;&lt;br /&gt;
ssl_dhparam /etc/nginx/dhparam.pem; # openssl dhparam -out /etc/nginx/dhparam.pem 4096&lt;br /&gt;
ssl_ciphers &amp;quot;EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH&amp;quot;;&lt;br /&gt;
ssl_ecdh_curve secp384r1; # Requires nginx &amp;gt;= 1.1.0&lt;br /&gt;
ssl_session_cache shared:SSL:10m;&lt;br /&gt;
ssl_session_tickets off; # Requires nginx &amp;gt;= 1.5.9&lt;br /&gt;
ssl_stapling on; # Requires nginx &amp;gt;= 1.3.7&lt;br /&gt;
ssl_stapling_verify on; # Requires nginx =&amp;gt; 1.3.7&lt;br /&gt;
resolver 8.8.8.8 8.8.4.4 valid=300s;&lt;br /&gt;
resolver_timeout 5s;&lt;br /&gt;
&lt;br /&gt;
# https://hstspreload.org&lt;br /&gt;
add_header Strict-Transport-Security &amp;quot;max-age=63072000&amp;quot; always; &lt;br /&gt;
# By default, HSTS header is not added to subdomain requests. If you have subdomains and want&lt;br /&gt;
# HSTS to apply to all of them, you should add the includeSubDomains variable like this:&lt;br /&gt;
#add_header Strict-Transport-Security &amp;quot;max-age=63072000; includeSubDomains&amp;quot; always;&lt;br /&gt;
&lt;br /&gt;
add_header X-Frame-Options DENY;&lt;br /&gt;
add_header X-Content-Type-Options nosniff;&lt;br /&gt;
add_header X-XSS-Protection &amp;quot;1; mode=block&amp;quot;;&lt;br /&gt;
add_header X-Robots-Tag none;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Diffie–Hellman Parameters ====&lt;br /&gt;
&lt;br /&gt;
In the above configuration &amp;lt;var&amp;gt;ssl_dhparam&amp;lt;/var&amp;gt; is used, so we need to generate a global &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file. We want to use a 4096 key size, but this can take a very long time. Because of this, we are adding an extra option (&amp;lt;var&amp;gt;dsaparam&amp;lt;/var&amp;gt;) to generate our &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file (see [https://wiki.openssl.org/index.php/Manual:Dhparam(1)#OPTIONS this] wiki section):&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096}}&lt;br /&gt;
&lt;br /&gt;
At this point, you should be able to (re)start your nginx server, but it will not use any of the security features yet.&lt;br /&gt;
&lt;br /&gt;
==== Per site configuration files (conf.d) ====&lt;br /&gt;
&lt;br /&gt;
Since Alpine v3.5, we ship &#039;&#039;&#039;NGINX&#039;&#039;&#039; with a &amp;lt;code&amp;gt;default.conf&amp;lt;/code&amp;gt; within the {{path|/etc/nginx/conf.d}} directory.&lt;br /&gt;
&lt;br /&gt;
To add support for another website, you can add files with the &#039;&#039;&#039;.conf&#039;&#039;&#039; extension to this directory:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Common configuration includes ====&lt;br /&gt;
&lt;br /&gt;
If you need to setup multiple proxy setups, you can include duplicated data such as shown below:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/proxy_set_header.inc|&amp;lt;nowiki&amp;gt;proxy_set_header    X-Forwarded-By       $server_addr:$server_port;&lt;br /&gt;
proxy_set_header    X-Forwarded-For      $remote_addr;&lt;br /&gt;
proxy_set_header    X-Forwarded-Proto    $scheme;&lt;br /&gt;
proxy_set_header    Host                 $host;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== acme-client ===&lt;br /&gt;
To allow &#039;&#039;&#039;NGINX&#039;&#039;&#039; to support https, we need to add certificates and support for ACME (Automatic Certificate Management Environment) responses.&lt;br /&gt;
&lt;br /&gt;
==== ACME responses ====&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/acme.inc|&amp;lt;nowiki&amp;gt;# Allow access to the ACME Challenge for Let&#039;s Encrypt&lt;br /&gt;
location ^~ /.well-known/acme-challenge {&lt;br /&gt;
    allow all;&lt;br /&gt;
    alias /var/www/acme;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
And add this to your proxy configuration:&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Automatic generation of certificates ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
{{Cat|/etc/periodic/weekly/acme-client|&amp;lt;nowiki&amp;gt;#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for host in $hosts; do&lt;br /&gt;
        acme-client -a https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf -Nnmv $host &amp;amp;&amp;amp; renew=1&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
[ &amp;quot;$renew&amp;quot; = 1 ] &amp;amp;&amp;amp; rc-service nginx reload&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Make it executable:&lt;br /&gt;
 chmod +x /etc/periodic/weekly/acme-client&lt;br /&gt;
&lt;br /&gt;
This script will run weekly to verify whether one of your certificates is outdated and renew them when needed.&lt;br /&gt;
&lt;br /&gt;
If you have several domains, you can add them to the &#039;&#039;&#039;hosts=&#039;&#039;&#039; variable with a space between each domain. This will create a separate certificate and key for each:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org example.com foo.org bar.io&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Initial generation of keys and certificates ====&lt;br /&gt;
&lt;br /&gt;
To create your initial certificates and keys, you have to run this manually the first time:&lt;br /&gt;
&lt;br /&gt;
 {{Cmd|/etc/periodic/weekly/acme-client}}&lt;br /&gt;
&lt;br /&gt;
Watch the output and see if all goes well. When it&#039;s finished, you should have files in:&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/alpinelinux.nl/fullchain.pem&lt;br /&gt;
 /etc/ssl/acme/private/alpinelinux.org/privkey.pem&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Per site HTTPS configuration ====&lt;br /&gt;
&lt;br /&gt;
Add the following below the previous HTTP configuration:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl http2;&lt;br /&gt;
    server_name             alpinelinux.org&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    include /etc/nginx/conf.d/ssl-params.inc; # SSL parameters&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Redirect HTTP to HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Shared configuration ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/redirect_http.inc|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
location / {&lt;br /&gt;
        return 301 https://$host$request_uri;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Update host configuration ====&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
    include       conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Complete host example with IPv6 support ===&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  80;&lt;br /&gt;
    listen                  [::]:80;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    include                 conf.d/acme.inc;&lt;br /&gt;
    include                 conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl http2;&lt;br /&gt;
    listen                  [::]:443 ssl http2;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    include /etc/nginx/conf.d/ssl-params.inc; # SSL parameters&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14205</id>
		<title>Nginx as reverse proxy with acme (letsencrypt)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14205"/>
		<updated>2017-12-10T10:48:04Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* Setup */ Separated SSL configuration to its own file to include it at HTTPS server block. SSL parameters is not needed at the HTTP server block.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This setup will allow you to have multiple servers/containers accessible via a single IP address with the added benefit of a centralized generation of [https://letsencrypt.org/ letsencrypt] certificates and secure https (according to &#039;&#039;&#039;ssllabs ssltest&#039;&#039;&#039;). Be aware that you first need to setup a regular HTTP server in order to be able to generate your HTTPS certificates and keys. After you have generated them, you can then add your HTTPS host based configuration.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
For this howto, we need three tools: [[Nginx|NGINX]], {{pkg|acme-client}} and {{pkg|libressl}} (to generate [https://wiki.openssl.org/index.php/Diffie-Hellman_parameters Diffie–Hellman Parameters]).&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk update&lt;br /&gt;
apk add nginx acme-client libressl}}&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTP ===&lt;br /&gt;
&lt;br /&gt;
==== Global configuration ====&lt;br /&gt;
&lt;br /&gt;
First step is to refactor our global &amp;lt;code&amp;gt;nginx.conf&amp;lt;/code&amp;gt;. Its target at a low traffic http server, to increase performance make changes at top level.&lt;br /&gt;
{{Cat|/etc/nginx/nginx.conf|&amp;lt;nowiki&amp;gt;# /etc/nginx/nginx.conf&lt;br /&gt;
&lt;br /&gt;
user nginx;&lt;br /&gt;
worker_processes 1; # use &amp;quot;auto&amp;quot; to use all available cores (high performance)&lt;br /&gt;
&lt;br /&gt;
# Configures default error logger.&lt;br /&gt;
error_log /var/log/nginx/error.log warn; # Log warn, error, crit, alert, emerg&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    # The maximum number of simultaneous connections that can be opened by a worker process.&lt;br /&gt;
    worker_connections 1024; # increase if you need more connections&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    # server_names_hash_bucket_size controls the maximum length&lt;br /&gt;
    # of a virtual host entry (ie the length of the domain name).&lt;br /&gt;
    server_names_hash_bucket_size   64; # controls the maximum length of a virtual host entry (ie domain name)&lt;br /&gt;
    server_tokens                   off; # hide who we are, don&#039;t show nginx version to clients&lt;br /&gt;
    sendfile                        off; # can cause issues&lt;br /&gt;
&lt;br /&gt;
    # nginx will find this file in the config directory set at nginx build time&lt;br /&gt;
    # Includes mapping of file name extensions to MIME types of responses&lt;br /&gt;
    include mime.types;&lt;br /&gt;
&lt;br /&gt;
    # fallback in case we can&#039;t determine a type&lt;br /&gt;
    default_type application/octet-stream;&lt;br /&gt;
&lt;br /&gt;
    # buffering causes issues, disable it&lt;br /&gt;
    # increase buffer size. still useful even when buffering is off&lt;br /&gt;
    proxy_buffering off;&lt;br /&gt;
    proxy_buffer_size 4k;&lt;br /&gt;
&lt;br /&gt;
    # allow the server to close the connection after a client stops responding. Frees up socket-associated memory.&lt;br /&gt;
    reset_timedout_connection on;&lt;br /&gt;
&lt;br /&gt;
    # Specifies the main log format.&lt;br /&gt;
    log_format main &#039;$remote_addr - $remote_user [$time_local] &amp;quot;$request&amp;quot; &#039;&lt;br /&gt;
            &#039;$status $body_bytes_sent &amp;quot;$http_referer&amp;quot; &#039;&lt;br /&gt;
            &#039;&amp;quot;$http_user_agent&amp;quot; &amp;quot;$http_x_forwarded_for&amp;quot;&#039;;&lt;br /&gt;
&lt;br /&gt;
    # Sets the path, format, and configuration for a buffered log write.&lt;br /&gt;
    # Buffer log writes to speed up IO, or disable them altogether&lt;br /&gt;
    access_log /var/log/nginx/access.log main buffer=16k;&lt;br /&gt;
    #access_log off;&lt;br /&gt;
&lt;br /&gt;
    # include virtual hosts configs&lt;br /&gt;
    include conf.d/*.conf;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== SSL configuration ====&lt;br /&gt;
&lt;br /&gt;
Configure a file with all SSL-parameters that we can include in the virtual hosts configs later on.&amp;lt;br&amp;gt;&lt;br /&gt;
The security settings are taken from https://cipherli.st. Please also read https://hstspreload.org for details about HSTS.&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/ssl-params.inc|&amp;lt;nowiki&amp;gt;# secure nginx, see https://cipherli.st/&lt;br /&gt;
&lt;br /&gt;
#ssl_protocols TLSv1.3; # Requires nginx &amp;gt;= 1.13.0 else use TLSv1.2&lt;br /&gt;
ssl_protocols TLSv1.2; # We use TLSv1.2 because current stable nginx release don&#039;t support TLSv1.3 yet&lt;br /&gt;
ssl_prefer_server_ciphers on;&lt;br /&gt;
ssl_dhparam /etc/nginx/dhparam.pem; # openssl dhparam -out /etc/nginx/dhparam.pem 4096&lt;br /&gt;
ssl_ciphers &amp;quot;EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH&amp;quot;;&lt;br /&gt;
ssl_ecdh_curve secp384r1; # Requires nginx &amp;gt;= 1.1.0&lt;br /&gt;
ssl_session_cache shared:SSL:10m;&lt;br /&gt;
ssl_session_tickets off; # Requires nginx &amp;gt;= 1.5.9&lt;br /&gt;
ssl_stapling on; # Requires nginx &amp;gt;= 1.3.7&lt;br /&gt;
ssl_stapling_verify on; # Requires nginx =&amp;gt; 1.3.7&lt;br /&gt;
resolver 8.8.8.8 8.8.4.4 valid=300s;&lt;br /&gt;
resolver_timeout 5s;&lt;br /&gt;
&lt;br /&gt;
# https://hstspreload.org&lt;br /&gt;
add_header Strict-Transport-Security &amp;quot;max-age=63072000&amp;quot; always; &lt;br /&gt;
# By default, HSTS header is not added to subdomain requests. If you have subdomains and want&lt;br /&gt;
# HSTS to apply to all of them, you should add the includeSubDomains variable like this:&lt;br /&gt;
#add_header Strict-Transport-Security &amp;quot;max-age=63072000; includeSubDomains&amp;quot; always;&lt;br /&gt;
&lt;br /&gt;
add_header X-Frame-Options DENY;&lt;br /&gt;
add_header X-Content-Type-Options nosniff;&lt;br /&gt;
add_header X-XSS-Protection &amp;quot;1; mode=block&amp;quot;;&lt;br /&gt;
add_header X-Robots-Tag none;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Diffie–Hellman Parameters ====&lt;br /&gt;
&lt;br /&gt;
In the above configuration &amp;lt;var&amp;gt;ssl_dhparam&amp;lt;/var&amp;gt; is used, so we need to generate a global &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file. We want to use a 4096 key size, but this can take a very long time. Because of this, we are adding an extra option (&amp;lt;var&amp;gt;dsaparam&amp;lt;/var&amp;gt;) to generate our &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file (see [https://wiki.openssl.org/index.php/Manual:Dhparam(1)#OPTIONS this] wiki section):&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096}}&lt;br /&gt;
&lt;br /&gt;
At this point, you should be able to (re)start your nginx server, but it will not use any of the security features yet.&lt;br /&gt;
&lt;br /&gt;
==== Per site configuration files (conf.d) ====&lt;br /&gt;
&lt;br /&gt;
Since Alpine v3.5, we ship &#039;&#039;&#039;NGINX&#039;&#039;&#039; with a &amp;lt;code&amp;gt;default.conf&amp;lt;/code&amp;gt; within the {{path|/etc/nginx/conf.d}} directory.&lt;br /&gt;
&lt;br /&gt;
To add support for another website, you can add files with the &#039;&#039;&#039;.conf&#039;&#039;&#039; extension to this directory:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Common configuration includes ====&lt;br /&gt;
&lt;br /&gt;
If you need to setup multiple proxy setups, you can include duplicated data such as shown below:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/proxy_set_header.inc|&amp;lt;nowiki&amp;gt;proxy_set_header    X-Forwarded-By       $server_addr:$server_port;&lt;br /&gt;
proxy_set_header    X-Forwarded-For      $remote_addr;&lt;br /&gt;
proxy_set_header    X-Forwarded-Proto    $scheme;&lt;br /&gt;
proxy_set_header    Host                 $host;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== acme-client ===&lt;br /&gt;
To allow &#039;&#039;&#039;NGINX&#039;&#039;&#039; to support https, we need to add certificates and support for ACME (Automatic Certificate Management Environment) responses.&lt;br /&gt;
&lt;br /&gt;
==== ACME responses ====&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/acme.inc|&amp;lt;nowiki&amp;gt;# Allow access to the ACME Challenge for Let&#039;s Encrypt&lt;br /&gt;
location ^~ /.well-known/acme-challenge {&lt;br /&gt;
    allow all;&lt;br /&gt;
    alias /var/www/acme;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
And add this to your proxy configuration:&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Automatic generation of certificates ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
{{Cat|/etc/periodic/weekly/acme-client|&amp;lt;nowiki&amp;gt;#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for host in $hosts; do&lt;br /&gt;
        acme-client -a https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf -Nnmv $host &amp;amp;&amp;amp; renew=1&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
[ &amp;quot;$renew&amp;quot; = 1 ] &amp;amp;&amp;amp; rc-service nginx reload&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Make it executable:&lt;br /&gt;
 chmod +x /etc/periodic/weekly/acme-client&lt;br /&gt;
&lt;br /&gt;
This script will run weekly to verify whether one of your certificates is outdated and renew them when needed.&lt;br /&gt;
&lt;br /&gt;
If you have several domains, you can add them to the &#039;&#039;&#039;hosts=&#039;&#039;&#039; variable with a space between each domain. This will create a separate certificate and key for each:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org example.com foo.org bar.io&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Initial generation of keys and certificates ====&lt;br /&gt;
&lt;br /&gt;
To create your initial certificates and keys, you have to run this manually the first time:&lt;br /&gt;
&lt;br /&gt;
 {{Cmd|/etc/periodic/weekly/acme-client}}&lt;br /&gt;
&lt;br /&gt;
Watch the output and see if all goes well. When it&#039;s finished, you should have files in:&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/alpinelinux.nl/fullchain.pem&lt;br /&gt;
 /etc/ssl/acme/private/alpinelinux.org/privkey.pem&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Per site HTTPS configuration ====&lt;br /&gt;
&lt;br /&gt;
Add the following below the previous HTTP configuration:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl http2;&lt;br /&gt;
    server_name             alpinelinux.org&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    include /etc/nginx/conf.d/ssl-params.inc; # SSL parameters&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Redirect HTTP to HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Shared configuration ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/redirect_http.inc|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
location / {&lt;br /&gt;
        return 301 https://$host$request_uri;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Update host configuration ====&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
    include       conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Complete host example with IPv6 support ===&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  80;&lt;br /&gt;
    listen                  [::]:80;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    include                 conf.d/acme.inc;&lt;br /&gt;
    include                 conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl http2;&lt;br /&gt;
    listen                  [::]:443 ssl http2;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    include /etc/nginx/conf.d/ssl-params.inc; # SSL parameters&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx&amp;diff=14204</id>
		<title>Nginx</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx&amp;diff=14204"/>
		<updated>2017-12-10T08:18:05Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* Controlling nginx */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://nginx.org/en/ Nginx] (engine x) is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP/UDP proxy server&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
Nginx package is available in the Alpine Linux repositories. To install it run:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk update&lt;br /&gt;
apk add nginx}}&lt;br /&gt;
&lt;br /&gt;
Creating new user and group &#039;www&#039; for nginx&lt;br /&gt;
{{Cmd|adduser -D -g &#039;www&#039; www}}&lt;br /&gt;
&lt;br /&gt;
Create a directory for html files&lt;br /&gt;
{{Cmd|mkdir /www&lt;br /&gt;
chown -R www:www /var/lib/nginx&lt;br /&gt;
chown -R www:www /www&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
You may want to make backup of original nginx.conf file before writting your own&lt;br /&gt;
{{Cmd|mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig}}&lt;br /&gt;
&lt;br /&gt;
Configuring Nginx to listen to port 80 and process .html or .htm files&lt;br /&gt;
{{Cmd|vi /etc/nginx/nginx.conf}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
user                            www;&lt;br /&gt;
worker_processes                1;&lt;br /&gt;
&lt;br /&gt;
error_log                       /var/log/nginx/error.log warn;&lt;br /&gt;
pid                             /var/run/nginx.pid;&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections          1024;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    include                     /etc/nginx/mime.types;&lt;br /&gt;
    default_type                application/octet-stream;&lt;br /&gt;
    sendfile                    on;&lt;br /&gt;
    access_log                  /var/log/nginx/access.log;&lt;br /&gt;
    keepalive_timeout           3000;&lt;br /&gt;
    server {&lt;br /&gt;
        listen                  80;&lt;br /&gt;
        root                    /www;&lt;br /&gt;
        index                   index.html index.htm;&lt;br /&gt;
        server_name             localhost;&lt;br /&gt;
        client_max_body_size    32m;&lt;br /&gt;
        error_page              500 502 503 504  /50x.html;&lt;br /&gt;
        location = /50x.html {&lt;br /&gt;
              root              /var/lib/nginx/html;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample page ==&lt;br /&gt;
{{Cmd|vi /www/index.html}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html lang=&amp;quot;en&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;meta charset=&amp;quot;utf-8&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;title&amp;gt;HTML5&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
    Server is online&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Controlling nginx ==&lt;br /&gt;
&lt;br /&gt;
=== Test configuration ===&lt;br /&gt;
When you&#039;ve made any changes to your nginx configuration files, you should check it for errors before starting/restarting/reloading nginx.&amp;lt;br&amp;gt;&lt;br /&gt;
This will check for any duplicate configuration, syntax errors etc. To do this, run:&lt;br /&gt;
{{Cmd|nginx -t}}&lt;br /&gt;
&lt;br /&gt;
You will get a feedback if it failed or not. If everything is fine, you&#039;ll see the following and can then move ahead to start the nginx server.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok&lt;br /&gt;
nginx: configuration file /etc/nginx/nginx.conf test is successful&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Start Nginx ===&lt;br /&gt;
After the installation Nginx is not running. To start Nginx, use &#039;&#039;start&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx start}}&lt;br /&gt;
&lt;br /&gt;
You will get a feedback about the status.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 * /run/nginx: creating directory&lt;br /&gt;
 * /run/nginx: correcting owner                         [ ok ]&lt;br /&gt;
 * Starting nginx ...                                   [ ok ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reload and Restart Nginx ===&lt;br /&gt;
Changes made in the configuration file will not be applied until the command to reload configuration is sent to nginx or it is restarted.&amp;lt;br&amp;gt;&lt;br /&gt;
Reloading will do a &amp;quot;hot reload&amp;quot; of the configuration without server downtime. It will start the new worker processes with a new configuration and gracefully shutdown the old worker processes. If you have pending requests, then these will be handled by the old worker processes before it dies, so it&#039;s an extremely graceful way to reload configs.&lt;br /&gt;
If you want to reload the web server, use &#039;&#039;reload&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx reload}}&lt;br /&gt;
If you want to restart the web server, use &#039;&#039;restart&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx restart}}&lt;br /&gt;
&lt;br /&gt;
=== Stop Nginx ===&lt;br /&gt;
If you want to stop the web server, use &#039;&#039;stop&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx stop}}&lt;br /&gt;
&lt;br /&gt;
=== Runlevel ===&lt;br /&gt;
Normally you want to start the web server when the system is launching. This is done by adding Nginx to the needed runlevel.&lt;br /&gt;
{{Cmd|rc-update add nginx default}}&lt;br /&gt;
&lt;br /&gt;
Now Nginx should start automatically when you boot your machine next time. To test that run:&lt;br /&gt;
{{cmd|reboot}}&lt;br /&gt;
&lt;br /&gt;
To make sure that Nginx is started run:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;ps aux | grep nginx&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You should get something like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  263 root       0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf&lt;br /&gt;
  264 www        0:00 nginx: worker process&lt;br /&gt;
  310 root       0:00 grep nginx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Nginx ==&lt;br /&gt;
This section is assuming that nginx is running and sample html page &amp;quot;/www/index.html&amp;quot; is created. Launch a web browser and point it to your web server.&lt;br /&gt;
You should get:&lt;br /&gt;
&amp;lt;pre&amp;gt;Server is online&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
If Nginx is not started check Nginx log file&lt;br /&gt;
{{cmd|less /var/log/nginx/error.log}}&lt;br /&gt;
&lt;br /&gt;
Make sure that configuration file does not contain errors&lt;br /&gt;
{{cmd|vi /etc/nginx/nginx.conf}}&lt;br /&gt;
&lt;br /&gt;
== Nginx with PHP ==&lt;br /&gt;
&lt;br /&gt;
[[Nginx_with_PHP#Nginx_with_PHP|Setting Up Nginx with PHP]] &amp;lt;br&amp;gt;&lt;br /&gt;
[[Nginx_as_reverse_proxy_with_acme_(letsencrypt)|Setting Up Nginx as Reverse Proxy with acme (Let&#039;s Encrypt)]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx&amp;diff=14203</id>
		<title>Nginx</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx&amp;diff=14203"/>
		<updated>2017-12-10T08:10:34Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://nginx.org/en/ Nginx] (engine x) is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP/UDP proxy server&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
Nginx package is available in the Alpine Linux repositories. To install it run:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk update&lt;br /&gt;
apk add nginx}}&lt;br /&gt;
&lt;br /&gt;
Creating new user and group &#039;www&#039; for nginx&lt;br /&gt;
{{Cmd|adduser -D -g &#039;www&#039; www}}&lt;br /&gt;
&lt;br /&gt;
Create a directory for html files&lt;br /&gt;
{{Cmd|mkdir /www&lt;br /&gt;
chown -R www:www /var/lib/nginx&lt;br /&gt;
chown -R www:www /www&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
You may want to make backup of original nginx.conf file before writting your own&lt;br /&gt;
{{Cmd|mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig}}&lt;br /&gt;
&lt;br /&gt;
Configuring Nginx to listen to port 80 and process .html or .htm files&lt;br /&gt;
{{Cmd|vi /etc/nginx/nginx.conf}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
user                            www;&lt;br /&gt;
worker_processes                1;&lt;br /&gt;
&lt;br /&gt;
error_log                       /var/log/nginx/error.log warn;&lt;br /&gt;
pid                             /var/run/nginx.pid;&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections          1024;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    include                     /etc/nginx/mime.types;&lt;br /&gt;
    default_type                application/octet-stream;&lt;br /&gt;
    sendfile                    on;&lt;br /&gt;
    access_log                  /var/log/nginx/access.log;&lt;br /&gt;
    keepalive_timeout           3000;&lt;br /&gt;
    server {&lt;br /&gt;
        listen                  80;&lt;br /&gt;
        root                    /www;&lt;br /&gt;
        index                   index.html index.htm;&lt;br /&gt;
        server_name             localhost;&lt;br /&gt;
        client_max_body_size    32m;&lt;br /&gt;
        error_page              500 502 503 504  /50x.html;&lt;br /&gt;
        location = /50x.html {&lt;br /&gt;
              root              /var/lib/nginx/html;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample page ==&lt;br /&gt;
{{Cmd|vi /www/index.html}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html lang=&amp;quot;en&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;meta charset=&amp;quot;utf-8&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;title&amp;gt;HTML5&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
    Server is online&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Controlling nginx ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Start Nginx ===&lt;br /&gt;
After the installation Nginx is not running. To start Nginx, use &#039;&#039;start&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx start}}&lt;br /&gt;
&lt;br /&gt;
You will get a feedback about the status.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 * /run/nginx: creating directory&lt;br /&gt;
 * /run/nginx: correcting owner                         [ ok ]&lt;br /&gt;
 * Starting nginx ...                                   [ ok ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reload and Restart Nginx ===&lt;br /&gt;
Changes made in the configuration file will not be applied until the command to reload configuration is sent to nginx or it is restarted.&amp;lt;br&amp;gt;&lt;br /&gt;
Reloading will do a &amp;quot;hot reload&amp;quot; of the configuration without server downtime. It will start the new worker processes with a new configuration and gracefully shutdown the old worker processes. If you have pending requests, then these will be handled by the old worker processes before it dies, so it&#039;s an extremely graceful way to reload configs.&lt;br /&gt;
If you want to reload the web server, use &#039;&#039;reload&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx reload}}&lt;br /&gt;
If you want to restart the web server, use &#039;&#039;restart&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx restart}}&lt;br /&gt;
&lt;br /&gt;
=== Stop Nginx ===&lt;br /&gt;
If you want to stop the web server, use &#039;&#039;stop&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx stop}}&lt;br /&gt;
&lt;br /&gt;
=== Runlevel ===&lt;br /&gt;
Normally you want to start the web server when the system is launching. This is done by adding Nginx to the needed runlevel.&lt;br /&gt;
{{Cmd|rc-update add nginx default}}&lt;br /&gt;
&lt;br /&gt;
Now Nginx should start automatically when you boot your machine next time. To test that run:&lt;br /&gt;
{{cmd|reboot}}&lt;br /&gt;
&lt;br /&gt;
To make sure that Nginx is started run:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;ps aux | grep nginx&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You should get something like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  263 root       0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf&lt;br /&gt;
  264 www        0:00 nginx: worker process&lt;br /&gt;
  310 root       0:00 grep nginx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Nginx ==&lt;br /&gt;
This section is assuming that nginx is running and sample html page &amp;quot;/www/index.html&amp;quot; is created. Launch a web browser and point it to your web server.&lt;br /&gt;
You should get:&lt;br /&gt;
&amp;lt;pre&amp;gt;Server is online&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
If Nginx is not started check Nginx log file&lt;br /&gt;
{{cmd|less /var/log/nginx/error.log}}&lt;br /&gt;
&lt;br /&gt;
Make sure that configuration file does not contain errors&lt;br /&gt;
{{cmd|vi /etc/nginx/nginx.conf}}&lt;br /&gt;
&lt;br /&gt;
== Nginx with PHP ==&lt;br /&gt;
&lt;br /&gt;
[[Nginx_with_PHP#Nginx_with_PHP|Setting Up Nginx with PHP]] &amp;lt;br&amp;gt;&lt;br /&gt;
[[Nginx_as_reverse_proxy_with_acme_(letsencrypt)|Setting Up Nginx as Reverse Proxy with acme (Let&#039;s Encrypt)]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx&amp;diff=14202</id>
		<title>Nginx</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx&amp;diff=14202"/>
		<updated>2017-12-10T08:07:48Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://nginx.org/en/ Nginx] (engine x) is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP/UDP proxy server&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
Nginx package is available in the Alpine Linux repositories. To install it run:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk update&lt;br /&gt;
apk add nginx}}&lt;br /&gt;
&lt;br /&gt;
Creating new user and group &#039;www&#039; for nginx&lt;br /&gt;
{{Cmd|adduser -D -u 1000 -g &#039;www&#039; www}}&lt;br /&gt;
&lt;br /&gt;
Create a directory for html files&lt;br /&gt;
{{Cmd|mkdir /www&lt;br /&gt;
chown -R www:www /var/lib/nginx&lt;br /&gt;
chown -R www:www /www&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
You may want to make backup of original nginx.conf file before writting your own&lt;br /&gt;
{{Cmd|mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig}}&lt;br /&gt;
&lt;br /&gt;
Configuring Nginx to listen to port 80 and process .html or .htm files&lt;br /&gt;
{{Cmd|vi /etc/nginx/nginx.conf}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
user                            www;&lt;br /&gt;
worker_processes                1;&lt;br /&gt;
&lt;br /&gt;
error_log                       /var/log/nginx/error.log warn;&lt;br /&gt;
pid                             /var/run/nginx.pid;&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections          1024;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    include                     /etc/nginx/mime.types;&lt;br /&gt;
    default_type                application/octet-stream;&lt;br /&gt;
    sendfile                    on;&lt;br /&gt;
    access_log                  /var/log/nginx/access.log;&lt;br /&gt;
    keepalive_timeout           3000;&lt;br /&gt;
    server {&lt;br /&gt;
        listen                  80;&lt;br /&gt;
        root                    /www;&lt;br /&gt;
        index                   index.html index.htm;&lt;br /&gt;
        server_name             localhost;&lt;br /&gt;
        client_max_body_size    32m;&lt;br /&gt;
        error_page              500 502 503 504  /50x.html;&lt;br /&gt;
        location = /50x.html {&lt;br /&gt;
              root              /var/lib/nginx/html;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample page ==&lt;br /&gt;
{{Cmd|vi /www/index.html}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html lang=&amp;quot;en&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;meta charset=&amp;quot;utf-8&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;title&amp;gt;HTML5&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
    Server is online&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Controlling nginx ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Start Nginx ===&lt;br /&gt;
After the installation Nginx is not running. To start Nginx, use &#039;&#039;start&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx start}}&lt;br /&gt;
&lt;br /&gt;
You will get a feedback about the status.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 * /run/nginx: creating directory&lt;br /&gt;
 * /run/nginx: correcting owner                         [ ok ]&lt;br /&gt;
 * Starting nginx ...                                   [ ok ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reload and Restart Nginx ===&lt;br /&gt;
Changes made in the configuration file will not be applied until the command to reload configuration is sent to nginx or it is restarted.&amp;lt;br&amp;gt;&lt;br /&gt;
Reloading will do a &amp;quot;hot reload&amp;quot; of the configuration without server downtime. It will start the new worker processes with a new configuration and gracefully shutdown the old worker processes. If you have pending requests, then these will be handled by the old worker processes before it dies, so it&#039;s an extremely graceful way to reload configs.&lt;br /&gt;
If you want to reload the web server, use &#039;&#039;reload&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx reload}}&lt;br /&gt;
If you want to restart the web server, use &#039;&#039;restart&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx restart}}&lt;br /&gt;
&lt;br /&gt;
=== Stop Nginx ===&lt;br /&gt;
If you want to stop the web server, use &#039;&#039;stop&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx stop}}&lt;br /&gt;
&lt;br /&gt;
=== Runlevel ===&lt;br /&gt;
Normally you want to start the web server when the system is launching. This is done by adding Nginx to the needed runlevel.&lt;br /&gt;
{{Cmd|rc-update add nginx default}}&lt;br /&gt;
&lt;br /&gt;
Now Nginx should start automatically when you boot your machine next time. To test that run:&lt;br /&gt;
{{cmd|reboot}}&lt;br /&gt;
&lt;br /&gt;
To make sure that Nginx is started run:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;ps aux | grep nginx&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You should get something like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  263 root       0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf&lt;br /&gt;
  264 www        0:00 nginx: worker process&lt;br /&gt;
  310 root       0:00 grep nginx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Nginx ==&lt;br /&gt;
This section is assuming that nginx is running and sample html page &amp;quot;/www/index.html&amp;quot; is created. Launch a web browser and point it to your web server.&lt;br /&gt;
You should get:&lt;br /&gt;
&amp;lt;pre&amp;gt;Server is online&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
If Nginx is not started check Nginx log file&lt;br /&gt;
{{cmd|less /var/log/nginx/error.log}}&lt;br /&gt;
&lt;br /&gt;
Make sure that configuration file does not contain errors&lt;br /&gt;
{{cmd|vi /etc/nginx/nginx.conf}}&lt;br /&gt;
&lt;br /&gt;
== Nginx with PHP ==&lt;br /&gt;
&lt;br /&gt;
[[Nginx_with_PHP#Nginx_with_PHP|Setting Up Nginx with PHP]] &amp;lt;br&amp;gt;&lt;br /&gt;
[[Nginx_as_reverse_proxy_with_acme_(letsencrypt)|Setting Up Nginx as Reverse Proxy with acme (Let&#039;s Encrypt)]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx&amp;diff=14194</id>
		<title>Nginx</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx&amp;diff=14194"/>
		<updated>2017-12-09T13:23:54Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* Controlling nginx */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://nginx.org/en/ Nginx] (engine x) is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP/UDP proxy server&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
Nginx package is available in the Alpine Linux repositories. To install it run:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add nginx}}&lt;br /&gt;
&lt;br /&gt;
Creating new user and group &#039;www&#039; for nginx&lt;br /&gt;
{{Cmd|adduser -D -u 1000 -g &#039;www&#039; www}}&lt;br /&gt;
&lt;br /&gt;
Create a directory for html files&lt;br /&gt;
{{Cmd|mkdir /www&lt;br /&gt;
chown -R www:www /var/lib/nginx&lt;br /&gt;
chown -R www:www /www&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
You may want to make backup of original nginx.conf file before writting your own&lt;br /&gt;
{{Cmd|mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig}}&lt;br /&gt;
&lt;br /&gt;
Configuring Nginx to listen to port 80 and process .html or .htm files&lt;br /&gt;
{{Cmd|vi /etc/nginx/nginx.conf}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
user                            www;&lt;br /&gt;
worker_processes                1;&lt;br /&gt;
&lt;br /&gt;
error_log                       /var/log/nginx/error.log warn;&lt;br /&gt;
pid                             /var/run/nginx.pid;&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections          1024;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    include                     /etc/nginx/mime.types;&lt;br /&gt;
    default_type                application/octet-stream;&lt;br /&gt;
    sendfile                    on;&lt;br /&gt;
    access_log                  /var/log/nginx/access.log;&lt;br /&gt;
    keepalive_timeout           3000;&lt;br /&gt;
    server {&lt;br /&gt;
        listen                  80;&lt;br /&gt;
        root                    /www;&lt;br /&gt;
        index                   index.html index.htm;&lt;br /&gt;
        server_name             localhost;&lt;br /&gt;
        client_max_body_size    32m;&lt;br /&gt;
        error_page              500 502 503 504  /50x.html;&lt;br /&gt;
        location = /50x.html {&lt;br /&gt;
              root              /var/lib/nginx/html;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample page ==&lt;br /&gt;
{{Cmd|vi /www/index.html}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html lang=&amp;quot;en&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;meta charset=&amp;quot;utf-8&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;title&amp;gt;HTML5&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
    Server is online&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Controlling nginx ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Start Nginx ===&lt;br /&gt;
After the installation Nginx is not running. To start Nginx, use &#039;&#039;start&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx start}}&lt;br /&gt;
&lt;br /&gt;
You will get a feedback about the status.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 * /run/nginx: creating directory&lt;br /&gt;
 * /run/nginx: correcting owner                         [ ok ]&lt;br /&gt;
 * Starting nginx ...                                   [ ok ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Reload and Restart Nginx ===&lt;br /&gt;
Changes made in the configuration file will not be applied until the command to reload configuration is sent to nginx or it is restarted.&amp;lt;br&amp;gt;&lt;br /&gt;
Reloading will do a &amp;quot;hot reload&amp;quot; of the configuration without server downtime. It will start the new worker processes with a new configuration and gracefully shutdown the old worker processes. If you have pending requests, then these will be handled by the old worker processes before it dies, so it&#039;s an extremely graceful way to reload configs.&lt;br /&gt;
If you want to reload the web server, use &#039;&#039;reload&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx reload}}&lt;br /&gt;
If you want to restart the web server, use &#039;&#039;restart&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx restart}}&lt;br /&gt;
&lt;br /&gt;
=== Stop Nginx ===&lt;br /&gt;
If you want to stop the web server, use &#039;&#039;stop&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx stop}}&lt;br /&gt;
&lt;br /&gt;
=== Runlevel ===&lt;br /&gt;
Normally you want to start the web server when the system is launching. This is done by adding Nginx to the needed runlevel.&lt;br /&gt;
{{Cmd|rc-update add nginx default}}&lt;br /&gt;
&lt;br /&gt;
Now Nginx should start automatically when you boot your machine next time. To test that run:&lt;br /&gt;
{{cmd|reboot}}&lt;br /&gt;
&lt;br /&gt;
To make sure that Nginx is started run:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;ps aux | grep nginx&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You should get something like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  263 root       0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf&lt;br /&gt;
  264 www        0:00 nginx: worker process&lt;br /&gt;
  310 root       0:00 grep nginx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Nginx ==&lt;br /&gt;
This section is assuming that nginx is running and sample html page &amp;quot;/www/index.html&amp;quot; is created. Launch a web browser and point it to your web server.&lt;br /&gt;
You should get:&lt;br /&gt;
&amp;lt;pre&amp;gt;Server is online&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
If Nginx is not started check Nginx log file&lt;br /&gt;
{{cmd|less /var/log/nginx/error.log}}&lt;br /&gt;
&lt;br /&gt;
Make sure that configuration file does not contain errors&lt;br /&gt;
{{cmd|vi /etc/nginx/nginx.conf}}&lt;br /&gt;
&lt;br /&gt;
== Nginx with PHP ==&lt;br /&gt;
&lt;br /&gt;
[[Nginx_with_PHP#Nginx_with_PHP|Setting Up Nginx with PHP]] &amp;lt;br&amp;gt;&lt;br /&gt;
[[Nginx_as_reverse_proxy_with_acme_(letsencrypt)|Setting Up Nginx as Reverse Proxy with acme (Let&#039;s Encrypt)]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Tutorials_and_Howtos&amp;diff=14193</id>
		<title>Tutorials and Howtos</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Tutorials_and_Howtos&amp;diff=14193"/>
		<updated>2017-12-09T12:09:36Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* HTTP */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:package_edutainment.svg|right|link=]]&lt;br /&gt;
{{TOC left}}&lt;br /&gt;
&#039;&#039;&#039;Welcome to Tutorials and Howtos, a place of basic and advanced configuration tasks for your Alpine Linux.&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
The tutorials are hands-on and the reader is expected to try and achieve the goals described in each step, possibly with the help of a good example. The output in one step is the starting point for the following step.&lt;br /&gt;
&lt;br /&gt;
Howtos are smaller articles explaining how to perform a particular task with Alpine Linux.&lt;br /&gt;
&lt;br /&gt;
We encourage people to send in both complete articles as well as requesting topics to be covered. If you think you have the skills and knowledge to write an Alpine Linux related article please do so on this Wiki. If you want to request a topic, please add your request in this page&#039;s [[Talk:Tutorials_and_Howtos|Discussion]].&lt;br /&gt;
&lt;br /&gt;
{{Clear}}&lt;br /&gt;
== Storage ==&lt;br /&gt;
&lt;br /&gt;
* [[Alpine local backup|Alpine local backup (lbu)]] &#039;&#039;(Permanently store your modifications in case your box needs reboot)&#039;&#039; &amp;lt;!-- Installation and Storage --&amp;gt;&lt;br /&gt;
** [[Back Up a Flash Memory Installation]] &amp;lt;!-- Installation and Storage --&amp;gt;&lt;br /&gt;
** [[Manually editing a existing apkovl]]&lt;br /&gt;
&lt;br /&gt;
* [[Setting up disks manually]] &amp;lt;!-- Installation and Storage --&amp;gt;&lt;br /&gt;
* [[Setting up a software RAID array]]&lt;br /&gt;
&amp;lt;!-- ** [[Setting up a /var partition on software IDE raid1]]  Obsolete, Installation and Storage --&amp;gt; &lt;br /&gt;
* [[Raid Administration]]&lt;br /&gt;
* [[Setting up encrypted volumes with LUKS]]&lt;br /&gt;
* [[Setting up LVM on LUKS]]&lt;br /&gt;
* [[Setting up Logical Volumes with LVM]]&lt;br /&gt;
** [[Setting up LVM on GPT-labeled disks]]&lt;br /&gt;
** [[Installing on GPT LVM]]&lt;br /&gt;
* [[Filesystems|Formatting HD/Floppy/Other]] &amp;lt;!-- just a stub --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Setting up iSCSI]]&lt;br /&gt;
** [[iSCSI Raid and Clustered File Systems]]&lt;br /&gt;
* [[Setting up NBD]]&lt;br /&gt;
* [[High performance SCST iSCSI Target on Linux software Raid]] &#039;&#039;(deprecated)&#039;&#039; &amp;lt;!-- solution --&amp;gt;&lt;br /&gt;
* [[Linux iSCSI Target (TCM)]]&lt;br /&gt;
* [[Disk Replication with DRBD]] &amp;lt;!-- draft --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Burning ISOs]] &amp;lt;!-- just some links now --&amp;gt;&lt;br /&gt;
* [[Partitioning and Bootmanagers]]&lt;br /&gt;
* [[Migrating data]]&lt;br /&gt;
* [[Create a bootable SDHC from a Mac]]&lt;br /&gt;
* [[Alpine on ARM]]&lt;br /&gt;
&lt;br /&gt;
== Networking ==&lt;br /&gt;
&lt;br /&gt;
* [[Configure Networking]]&lt;br /&gt;
* [[Connecting to a wireless access point]]&lt;br /&gt;
* [[Bonding]]&lt;br /&gt;
* [[Vlan]]&lt;br /&gt;
* [[Bridge]]&lt;br /&gt;
* [[OpenVSwitch]]&lt;br /&gt;
* [[How to configure static routes]]&lt;br /&gt;
&lt;br /&gt;
* [[Alpine Wall]] - [[How-To Alpine Wall]] - [[Alpine Wall User&#039;s Guide]] &#039;&#039;(a new firewall management framework)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[PXE boot]]&lt;br /&gt;
&lt;br /&gt;
* [[Using serial modem]]&lt;br /&gt;
* [[Using HSDPA modem]]&lt;br /&gt;
* [[Setting up Satellite Internet Connection]]&lt;br /&gt;
* [[Using Alpine on Windows domain with IPSEC isolation]]&lt;br /&gt;
&lt;br /&gt;
* [[Setting up a ssh-server]] &#039;&#039;(Using ssh is a good way to administer your box remotely)&#039;&#039; &amp;lt;!-- Server and Networking --&amp;gt;&lt;br /&gt;
* [[How to setup a wireless access point]] &#039;&#039;(Setting up Secure Wireless AP w/ WPA encryption with bridge to wired network)&#039;&#039;&lt;br /&gt;
* [[Setting up a OpenVPN server with Alpine]] &#039;&#039;(Allowing single users or devices to remotely connect to your network)&#039;&#039;&lt;br /&gt;
&amp;lt;!-- [[Using Racoon for Remote Sites]] is a different VPN tunnelling method, but that article is just a stub --&amp;gt;&lt;br /&gt;
* [[Experiences with OpenVPN-client on ALIX.2D3]]  &amp;lt;!-- solution --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Generating SSL certs with ACF]] &amp;lt;!-- Generating SSL certs with ACF 1.9 --&amp;gt;&lt;br /&gt;
* [[Setting up unbound DNS server]]&lt;br /&gt;
* [[Setting up nsd DNS server]]&lt;br /&gt;
* [[TinyDNS Format]]&lt;br /&gt;
* [[Fault Tolerant Routing with Alpine Linux]] &amp;lt;!-- solution --&amp;gt;&lt;br /&gt;
* [[Freeradius Active Directory Integration]]&lt;br /&gt;
* [[Multi_ISP]] &#039;&#039;(Dual-ISP setup with load-balancing and automatic failover)&#039;&#039;&lt;br /&gt;
* [[OwnCloud]] &#039;&#039;(Installing OwnCloud)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[Seafile: setting up your own private cloud]]&lt;br /&gt;
&lt;br /&gt;
== Post-Install ==&lt;br /&gt;
&amp;lt;!-- If you edit this, please coordinate with Installation#Post-Install and Developer_Documentation#Package_management.  Note that these three sections are not exact duplicates. --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Alpine Linux package management|Package Management (apk)]] &#039;&#039;(How to add/remove packages on your Alpine)&#039;&#039;&lt;br /&gt;
   &amp;lt;!-- [[Alpine Linux package management#Local_Cache|How to enable APK caching]] --&amp;gt;&lt;br /&gt;
** [[Comparison with other distros]]&lt;br /&gt;
* [[Alpine local backup|Alpine local backup (lbu)]] &#039;&#039;(Permanently store your modifications in case your box needs reboot)&#039;&#039;&lt;br /&gt;
** [[Back Up a Flash Memory Installation]] &amp;lt;!-- new --&amp;gt;&lt;br /&gt;
** [[Manually editing a existing apkovl]]&lt;br /&gt;
* [[Alpine Linux Init System|Init System (OpenRC)]] &#039;&#039;(Configure a service to automatically boot at next reboot)&#039;&#039;&lt;br /&gt;
** [[Multiple Instances of Services]]&lt;br /&gt;
   &amp;lt;!-- [[Writing Init Scripts]] --&amp;gt;&lt;br /&gt;
* [[Alpine setup scripts#setup-xorg-base|Setting up Xorg]]&lt;br /&gt;
* [[Upgrading Alpine]]&lt;br /&gt;
&amp;lt;!-- Obsolete&lt;br /&gt;
 [[Upgrading Alpine - v1.9.x]]&lt;br /&gt;
 [[Upgrading Alpine - CD v1.8.x]]&lt;br /&gt;
 [[Upgrading Alpine - HD v1.8.x]]&lt;br /&gt;
 [[Upgrade to repository main|Upgrading to signed repositories]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Setting up a ssh-server]] &#039;&#039;(Using ssh is a good way to administer your box remotely)&#039;&#039;&lt;br /&gt;
* [[setup-acf]] &#039;&#039;(Configures ACF (webconfiguration) so you can manage your box through https)&#039;&#039;&lt;br /&gt;
* [[Changing passwords for ACF|Changing passwords]]&lt;br /&gt;
* [[Ansible]] &#039;&#039;(Configuration management)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[Enable Serial Console on Boot]]&lt;br /&gt;
&amp;lt;!-- Obsolete?&lt;br /&gt;
* [[Error message on boot: Address space collision: host bridge window conflicts with Adaptor ROM]]&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
* [[How to get regular stuff working]] &#039;&#039;some notes on need-to-know topics&#039;&#039;&lt;br /&gt;
* [[Installing Oracle Java]]&lt;br /&gt;
* [[Rsnapshot|Setting up periodic backups with &amp;lt;samp&amp;gt;rsnapshot&amp;lt;/samp&amp;gt;]]&lt;br /&gt;
&lt;br /&gt;
== Virtualization==&lt;br /&gt;
&lt;br /&gt;
* [[Xen Dom0]] &#039;&#039;(Setting up Alpine as a dom0 for Xen hypervisor)&#039;&#039;&lt;br /&gt;
* [[Xen Dom0 on USB or SD]]&lt;br /&gt;
* [[Create Alpine Linux PV DomU]]&lt;br /&gt;
* [[Xen PCI Passthrough]]&lt;br /&gt;
* [[Xen LiveCD]]&lt;br /&gt;
* [[qemu]]&lt;br /&gt;
* [[KVM]] &#039;&#039;(Setting up Alpine as a KVM hypervisor)&#039;&#039;&lt;br /&gt;
* [[LXC]] &#039;&#039;(Setting up a Linux container in Alpine Linux)&#039;&#039;&lt;br /&gt;
* [[Docker]]&lt;br /&gt;
* [[Install_Alpine_on_VirtualBox]]&lt;br /&gt;
&lt;br /&gt;
== Desktop Environment ==&lt;br /&gt;
&lt;br /&gt;
* [[Awesome(wm) Setup]]&lt;br /&gt;
* [[EyeOS]] &#039;&#039;(Cloud Computing Desktop)&#039;&#039;&lt;br /&gt;
* [[Gnome Setup]]&lt;br /&gt;
* [[MATE|MATE Setup]]&lt;br /&gt;
* [[Oneye]] &#039;&#039;(Cloud Computing Desktop - Dropbox Alternative)&#039;&#039;&lt;br /&gt;
* [[Owncloud]] &#039;&#039;(Cloud Computing Desktop - Dropbox Alternative)&#039;&#039;&lt;br /&gt;
** (to be merged with [[OwnCloud]] &#039;&#039;(Your personal Cloud for storing and sharing your data on-line)&#039;&#039;)&lt;br /&gt;
* [[Remote Desktop Server]]&lt;br /&gt;
* [[Suspend on LID close]]&lt;br /&gt;
* [[XFCE Setup]] and [[Xfce Desktop|Desktop Ideas]]&lt;br /&gt;
* [[Installing Adobe flash player for Firefox]]&lt;br /&gt;
* [[Sound Setup]]&lt;br /&gt;
* [[Printer Setup]]&lt;br /&gt;
* [[Default applications]]&lt;br /&gt;
&lt;br /&gt;
== Raspberry Pi ==&lt;br /&gt;
&lt;br /&gt;
* [[Raspberry Pi|Raspberry Pi (Installation)]]&lt;br /&gt;
* [[Classic install or sys mode on Raspberry Pi]]&lt;br /&gt;
* [[RPI Video Receiver]] &#039;&#039;(network video decoder using Rasperry Pi and omxplayer)&#039;&#039;&lt;br /&gt;
* [[Linux Router with VPN on a Raspberry Pi]]&lt;br /&gt;
* [[Raspberry Pi 3 - Configuring it as wireless access point -AP Mode]]&lt;br /&gt;
* [[Raspberry Pi 3 - Setting Up Bluetooth]]&lt;br /&gt;
&lt;br /&gt;
== Applications ==&lt;br /&gt;
&lt;br /&gt;
=== Telephony ===&lt;br /&gt;
* [[Setting up Zaptel/Asterisk on Alpine]]&lt;br /&gt;
** [[Setting up Streaming an Asterisk Channel]]&lt;br /&gt;
* [[Freepbx on Alpine Linux]]&lt;br /&gt;
* [[FreePBX_V3]] &#039;&#039;(FreeSWITCH, Asterisk GUI web acces tool)&#039;&#039;&lt;br /&gt;
* [[2600hz]] &#039;&#039;(FreeSWITCH, Asterisk GUI web access tool)&#039;&#039;&lt;br /&gt;
* [[Kamailio]] &#039;&#039;(SIP Server, formerly OpenSER)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Mail ===&lt;br /&gt;
* [[Hosting services on Alpine]] &#039;&#039;(Hosting mail, webservices and other services)&#039;&#039;&lt;br /&gt;
** [[Hosting Web/Email services on Alpine]]&lt;br /&gt;
* [[ISP Mail Server HowTo]] &amp;lt;!-- solution, Mail --&amp;gt;&lt;br /&gt;
** [[ISP Mail Server Upgrade 2.x]]&lt;br /&gt;
** [[ISP Mail Server 2.x HowTo]] &#039;&#039;(Beta, please test)&#039;&#039;&lt;br /&gt;
** [[ISP Mail Server 3.x HowTo]]&lt;br /&gt;
* [[Roundcube]] &#039;&#039;(Webmail system)&#039;&#039;&lt;br /&gt;
* [[Setting up postfix with virtual domains]]&lt;br /&gt;
* [[Protecting your email server with Alpine]]&lt;br /&gt;
* [[Setting up clamsmtp]]&lt;br /&gt;
* [[Setting up dovecot with imap and ssl]]&lt;br /&gt;
* [[relay email to gmail (msmtp, mailx, sendmail]]&lt;br /&gt;
&lt;br /&gt;
=== HTTP ===&lt;br /&gt;
* [[Lighttpd]]&lt;br /&gt;
** [[Lighttpd Https access]]&lt;br /&gt;
** [[Setting Up Lighttpd with PHP]]&lt;br /&gt;
** [[Setting Up Lighttpd With FastCGI]]&lt;br /&gt;
* [[Cherokee]]&lt;br /&gt;
* [[Nginx]]&lt;br /&gt;
** [[Nginx_with_PHP#Nginx_with_PHP|Nginx with PHP]]&lt;br /&gt;
** [[Nginx as reverse proxy with acme (letsencrypt)]]&lt;br /&gt;
* [[Apache]]&lt;br /&gt;
** [[Apache with php-fpm]]&lt;br /&gt;
** [[Setting Up Apache with PHP]]&lt;br /&gt;
** [[Apache authentication: NTLM Single Signon]]&lt;br /&gt;
&lt;br /&gt;
* [[High Availability High Performance Web Cache]] &#039;&#039;(uCarp + HAProxy for High Availability Services such as Squid web proxy)&#039;&#039; &amp;lt;!-- solution, Server --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[Setting up Transparent Squid Proxy]] &amp;lt;!-- draft --&amp;gt;&lt;br /&gt;
** [[SqStat]] &#039;&#039;(Script to look at active squid users connections)&#039;&#039;&lt;br /&gt;
** [[Obtaining user information via SNMP]] &#039;&#039;(Using squark-auth-snmp as a Squid authentication helper)&#039;&#039; &amp;lt;!-- Networking and Server, &amp;lt;== Using squark-auth-snmp --&amp;gt;&lt;br /&gt;
* [[Setting up Explicit Squid Proxy]]&lt;br /&gt;
&lt;br /&gt;
* [[Drupal]] &#039;&#039;(Content Management System (CMS) written in PHP)&#039;&#039;&lt;br /&gt;
* [[WordPress]] &#039;&#039;(Web software to create website or blog)&#039;&#039;&lt;br /&gt;
* [[MediaWiki]] &#039;&#039;(Free web-based wiki software application)&#039;&#039;&lt;br /&gt;
* [[DokuWiki]]&lt;br /&gt;
* [[Darkhttpd]]&lt;br /&gt;
* [[Tomcat]]&lt;br /&gt;
&lt;br /&gt;
=== Other Servers ===&lt;br /&gt;
* [[Setting up a ssh-server]] &#039;&#039;(Using ssh is a good way to administer your box remotely)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[Setting up a nfs-server]]&lt;br /&gt;
* [[Setting up a samba-server]] &#039;&#039;(standard file sharing)&#039;&#039;&lt;br /&gt;
* [[Setting up a samba-ad-dc]] &#039;&#039;(Active Directory compatible domain controller)&#039;&#039;&lt;br /&gt;
* [[Phpizabi]] &#039;&#039;(Social Networking Platform)&#039;&#039;&lt;br /&gt;
* [[Statusnet]] &#039;&#039;(Microblogging Platform)&#039;&#039;&lt;br /&gt;
* [[Pastebin]] &#039;&#039;(Pastebin software application)&#039;&#039;&lt;br /&gt;
* [[Setting up Transmission (bittorrent) with Clutch WebUI]]&lt;br /&gt;
&lt;br /&gt;
* [[Patchwork]] &#039;&#039;(Patch review management system)&#039;&#039;&lt;br /&gt;
* [[Redmine]] &#039;&#039;(Project management system)&#039;&#039;&lt;br /&gt;
* [[Request-Tracker]] &#039;&#039;(Ticket system)&#039;&#039;&lt;br /&gt;
* [[OsTicket]] &#039;&#039;(Ticket system)&#039;&#039;&lt;br /&gt;
* [[Setting up trac wiki|Trac]] &#039;&#039;(Enhanced wiki and issue tracking system for software development projects)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[Cgit]]&lt;br /&gt;
** [[Setting up a git repository server with gitolite and cgit]] &amp;lt;!-- doesn&#039;t exist yet --&amp;gt;&lt;br /&gt;
* [[Roundcube]] &#039;&#039;(Webmail system)&#039;&#039;&lt;br /&gt;
* [[Glpi]] &#039;&#039;(Manage inventory of technical resources)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[How to setup a Alpine Linux mirror]]&lt;br /&gt;
* [[Cups]]&lt;br /&gt;
* [[NgIRCd]] &#039;&#039;(Server for Internet Relay Chat/IRC)&#039;&#039;&lt;br /&gt;
* [[How To Setup Your Own IRC Network]] &#039;&#039;(Using {{Pkg|charybdis}} and {{Pkg|atheme-iris}})&#039;&#039;&lt;br /&gt;
* [[OpenVCP]] &#039;&#039;(VServer Control Panel)&#039;&#039;&lt;br /&gt;
* [[Mahara]] &#039;&#039;(E-portfolio and social networking system)&#039;&#039;&lt;br /&gt;
* [[Chrony and GPSD | Using chrony, gpsd, and a garmin LVC 18 as a Stratum 1 NTP source ]]&lt;br /&gt;
* [[Sending SMS using gnokii]]&lt;br /&gt;
* [[IPTV How To|Internet Protocol television (IPTV)]]&lt;br /&gt;
&lt;br /&gt;
=== Monitoring ===&lt;br /&gt;
* Setting up [[collectd]]&lt;br /&gt;
* [[Traffic monitoring]] &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
* [[Setting up traffic monitoring using rrdtool (and snmp)]] &amp;lt;!-- Monitoring --&amp;gt;&lt;br /&gt;
* [[Setting up monitoring using rrdtool (and rrdcollect)]]&lt;br /&gt;
* [[Setting up Cacti|Cacti]] &#039;&#039;(Front-end for rrdtool networking monitor)&#039;&#039;&lt;br /&gt;
* [[LTTng]] &#039;&#039;(Kernel and userspace tracing)&#039;&#039;&lt;br /&gt;
* [[Setting up Zabbix|Zabbix]] &#039;&#039;(Monitor and track the status of network services and hardware)&#039;&#039;&lt;br /&gt;
* [[Setting up A Network Monitoring and Inventory System]] &#039;&#039;(Nagios + OpenAudit and related components)&#039;&#039; &amp;lt;!-- draft, solution, Networking and Monitoring and Server --&amp;gt;&lt;br /&gt;
** [[Setting up NRPE daemon]] &#039;&#039;(Performs remote Nagios checks)&#039;&#039; &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
* [[Setting up Smokeping|Smokeping]] &#039;&#039;(Network latency monitoring)&#039;&#039; &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
** [[Setting up MRTG and Smokeping to Monitor Bandwidth Usage and Network Latency]]&lt;br /&gt;
* [[Setting Up Fprobe And Ntop|Ntop]] &#039;&#039;(NetFlow collection and analysis using a remote fprobe instance)&#039;&#039; &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
* [[Cvechecker]] &#039;&#039;(Compare installed packages for Common Vulnerabilities Exposure)&#039;&#039; &amp;lt;!-- Monitoring and Security --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* [[IP Accounting]] &amp;lt;!-- Networking and Monitoring --&amp;gt;&lt;br /&gt;
* [[Obtaining user information via SNMP]] &#039;&#039;(Using squark-auth-snmp as a Squid authentication helper)&#039;&#039; &amp;lt;!-- Networking and Server, &amp;lt;== Using squark-auth-snmp --&amp;gt;&lt;br /&gt;
* [[SqStat]] &#039;&#039;(Script to look at active squid users connections)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[Piwik]] &#039;&#039;(A real time web analytics software program)&#039;&#039;&lt;br /&gt;
* [[Awstats]] &#039;&#039;(Free log file analyzer)&#039;&#039;&lt;br /&gt;
* [[Intrusion Detection using Snort]]&lt;br /&gt;
** [[Intrusion Detection using Snort, Sguil, Barnyard and more]]&lt;br /&gt;
* [[Dglog]] &#039;&#039;(Log analyzer for the web content filter DansGuardian)&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
* [[Webmin]] &#039;&#039;(A web-based interface for Linux system)&#039;&#039;&lt;br /&gt;
* [[PhpPgAdmin]] &#039;&#039;(Web-based administration tool for PostgreSQL)&#039;&#039;&lt;br /&gt;
* [[PhpMyAdmin]] &#039;&#039;(Web-based administration tool for MYSQL)&#039;&#039;&lt;br /&gt;
* [[PhpSysInfo]] &#039;&#039;(A simple application that displays information about the host it&#039;s running on)&#039;&#039;&lt;br /&gt;
* [[Linfo]]&lt;br /&gt;
&lt;br /&gt;
* [[Setting up lm_sensors]]&lt;br /&gt;
&lt;br /&gt;
* [[ZoneMinder video camera security and surveillance]]&lt;br /&gt;
&lt;br /&gt;
== Misc ==&lt;br /&gt;
&lt;br /&gt;
* [[:Category:Shell]]&lt;br /&gt;
* [[:Category:Programming]]&lt;br /&gt;
* [[Running glibc programs]]&lt;br /&gt;
* [[:Category:Drivers]]&lt;br /&gt;
* [[:Category:Multimedia]]&lt;br /&gt;
* [[Kernel Modesetting]]&lt;br /&gt;
* [[CPU frequency scaling]]&lt;br /&gt;
&lt;br /&gt;
== Complete Solutions ==&lt;br /&gt;
* [[DIY Fully working Alpine Linux for Allwinner and Other ARM SOCs]]&lt;br /&gt;
* [[Replacing non-Alpine Linux with Alpine remotely]]&lt;br /&gt;
* [[High performance SCST iSCSI Target on Linux software Raid]]&lt;br /&gt;
* [[Fault Tolerant Routing with Alpine Linux]]&lt;br /&gt;
* [[Experiences with OpenVPN-client on ALIX.2D3]]&lt;br /&gt;
* [[Building a cloud with Alpine Linux]]&lt;br /&gt;
&lt;br /&gt;
* [[ISP Mail Server HowTo]] &#039;&#039;(Postfix+PostfixAdmin+DoveCot+Roundcube+ClamAV+Spamd - A full-serivce ISP mail server)&#039;&#039;&lt;br /&gt;
** [[ISP Mail Server Upgrade 2.x]]&lt;br /&gt;
** [[ISP Mail Server 2.x HowTo]] &#039;&#039;(Beta, please test)&#039;&#039;&lt;br /&gt;
* [[High Availability High Performance Web Cache]] &#039;&#039;(uCarp + HAProxy for High Availability Services such as Squid web proxy)&#039;&#039;&lt;br /&gt;
* [[Setting up A Network Monitoring and Inventory System]] &#039;&#039;(Nagios + OpenAudit and related components)&#039;&#039; &amp;lt;!-- draft --&amp;gt;&lt;br /&gt;
* [[Streaming Security Camera Video with VLC]]&lt;br /&gt;
* [[Dynamic Multipoint VPN (DMVPN)]] combined with [[Small_Office_Services]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
This does not attempt to be complete. Is it useful to have these listed here? I find them more accessible if grouped with their topics; also, an up-to-date list of all Draft or Obsolete pages can be found at [[Project:Wiki maintenance]].&lt;br /&gt;
&lt;br /&gt;
== Drafts ==&lt;br /&gt;
Currently unfinished/works-in-progress.&lt;br /&gt;
* [[Using Racoon for Remote Sites]]&lt;br /&gt;
* [[Setting up Transparent Squid Proxy]] &#039;&#039;(Covers Squid proxy and URL Filtering system)&#039;&#039;&lt;br /&gt;
** [[Obtaining user information via SNMP]] &#039;&#039;(Using the Squark Squid authentication helper)&#039;&#039; [!-- no longer a draft --]&lt;br /&gt;
* [[Setting up Streaming an Asterisk Channel]]&lt;br /&gt;
* [[Setting up A Network Monitoring and Inventory System]] &#039;&#039;(Nagios + OpenAudit and related components)&#039;&#039;&lt;br /&gt;
* [[Intrusion Detection using Snort]] &#039;&#039;(Installing and configuring Snort and related applications on Alpine 2.0.x)&#039;&#039;&lt;br /&gt;
* [[IP Accounting]] &#039;&#039;(Installing and configuring pmacct for IP Accounting, Netflow/sFlow collector)&#039;&#039;&lt;br /&gt;
* [[Disk Replication with DRBD]]&lt;br /&gt;
--&amp;gt;&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=User:Flaxe&amp;diff=14192</id>
		<title>User:Flaxe</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User:Flaxe&amp;diff=14192"/>
		<updated>2017-12-09T12:07:23Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hello :)&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14191</id>
		<title>Nginx as reverse proxy with acme (letsencrypt)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14191"/>
		<updated>2017-12-09T07:36:47Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This setup will allow you to have multiple servers/containers accessible via a single IP address with the added benefit of a centralized generation of [https://letsencrypt.org/ letsencrypt] certificates and secure https (according to &#039;&#039;&#039;ssllabs ssltest&#039;&#039;&#039;). Be aware that you first need to setup a regular HTTP server in order to be able to generate your HTTPS certificates and keys. After you have generated them, you can then add your HTTPS host based configuration.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
For this howto, we need three tools: [[Nginx|NGINX]], {{pkg|acme-client}} and {{pkg|libressl}} (to generate [https://wiki.openssl.org/index.php/Diffie-Hellman_parameters Diffie–Hellman Parameters]).&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk update&lt;br /&gt;
apk add nginx acme-client libressl}}&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTP ===&lt;br /&gt;
&lt;br /&gt;
==== Global configuration ====&lt;br /&gt;
&lt;br /&gt;
First step is to refactor our global &amp;lt;code&amp;gt;nginx.conf&amp;lt;/code&amp;gt;. Its target at a low traffic http server, to increase performance make changes at top level.&lt;br /&gt;
&lt;br /&gt;
The security settings are taken from https://cipherli.st. Please also read https://hstspreload.org for details about HSTS.&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/nginx.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
# /etc/nginx/nginx.conf&lt;br /&gt;
&lt;br /&gt;
user  nginx;&lt;br /&gt;
&lt;br /&gt;
worker_processes  1; # use &amp;quot;auto&amp;quot; to use all available cores (high performance)&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections  1024; # increase if you need more connections&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    # server_names_hash_bucket_size controls the maximum length&lt;br /&gt;
    # of a virtual host entry (ie the length of the domain name).&lt;br /&gt;
    server_names_hash_bucket_size   64;&lt;br /&gt;
    server_tokens                   off; # hide who we are&lt;br /&gt;
    sendfile                        off; # can cause issues&lt;br /&gt;
&lt;br /&gt;
    # secure nginx according to https://cipherli.st/&lt;br /&gt;
    #ssl_protocols TLSv1.3; # Requires nginx &amp;gt;= 1.13.0 else use TLSv1.2&lt;br /&gt;
    ssl_protocols TLSv1.2; # We use TLSv1.2 because current stable nginx release don&#039;t support TLSv1.3&lt;br /&gt;
    ssl_prefer_server_ciphers on;&lt;br /&gt;
    ssl_dhparam /etc/nginx/dhparam.pem; # openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096&lt;br /&gt;
    ssl_ciphers &amp;quot;EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH&amp;quot;;&lt;br /&gt;
    ssl_ecdh_curve secp384r1; # Requires nginx &amp;gt;= 1.1.0&lt;br /&gt;
    ssl_session_cache shared:SSL:10m;&lt;br /&gt;
    ssl_session_tickets off; # Requires nginx &amp;gt;= 1.5.9&lt;br /&gt;
    ssl_stapling on; # Requires nginx &amp;gt;= 1.3.7&lt;br /&gt;
    ssl_stapling_verify on; # Requires nginx =&amp;gt; 1.3.7&lt;br /&gt;
    resolver 8.8.8.8 8.8.4.4 valid=300s;&lt;br /&gt;
    resolver_timeout 5s;&lt;br /&gt;
    add_header Strict-Transport-Security &amp;quot;max-age=63072000&amp;quot;; # https://hstspreload.org&lt;br /&gt;
    add_header X-Frame-Options DENY;&lt;br /&gt;
    add_header X-Content-Type-Options nosniff;&lt;br /&gt;
    add_header X-XSS-Protection &amp;quot;1; mode=block&amp;quot;;&lt;br /&gt;
    add_header X-Robots-Tag none; &lt;br /&gt;
&lt;br /&gt;
    # nginx will find this file in the config directory set at nginx build time&lt;br /&gt;
    include mime.types;&lt;br /&gt;
&lt;br /&gt;
    #fallback in case we can&#039;t determine a type&lt;br /&gt;
    default_type application/octet-stream;&lt;br /&gt;
&lt;br /&gt;
    # buffering causes issues&lt;br /&gt;
    proxy_buffering off;&lt;br /&gt;
&lt;br /&gt;
    # include hosts&lt;br /&gt;
    include conf.d/*.conf;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Diffie–Hellman Parameters ====&lt;br /&gt;
&lt;br /&gt;
In the above configuration &amp;lt;var&amp;gt;ssl_dhparam&amp;lt;/var&amp;gt; is used, so we need to generate a global &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file. We want to use a 4096 key size, but this can take a very long time. Because of this, we are adding an extra option (&amp;lt;var&amp;gt;dsaparam&amp;lt;/var&amp;gt;) to generate our &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file (see [https://wiki.openssl.org/index.php/Manual:Dhparam(1)#OPTIONS this] wiki section):&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096}}&lt;br /&gt;
&lt;br /&gt;
At this point, you should be able to (re)start your nginx server, but it will not use any of the security features yet.&lt;br /&gt;
&lt;br /&gt;
==== Per site configuration files (conf.d) ====&lt;br /&gt;
&lt;br /&gt;
Since Alpine v3.5, we ship &#039;&#039;&#039;NGINX&#039;&#039;&#039; with a &amp;lt;code&amp;gt;default.conf&amp;lt;/code&amp;gt; within the {{path|/etc/nginx/conf.d}} directory.&lt;br /&gt;
&lt;br /&gt;
To add support for another website, you can add files with the &#039;&#039;&#039;.conf&#039;&#039;&#039; extension to this directory:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Common configuration includes ====&lt;br /&gt;
&lt;br /&gt;
If you need to setup multiple proxy setups, you can include duplicated data such as shown below:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/proxy_set_header.inc|&amp;lt;nowiki&amp;gt;proxy_set_header    X-Forwarded-By       $server_addr:$server_port;&lt;br /&gt;
proxy_set_header    X-Forwarded-For      $remote_addr;&lt;br /&gt;
proxy_set_header    X-Forwarded-Proto    $scheme;&lt;br /&gt;
proxy_set_header    Host                 $host;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== acme-client ===&lt;br /&gt;
&lt;br /&gt;
To allow &#039;&#039;&#039;NGINX&#039;&#039;&#039; to support https, we need to add certificates and support for ACME (Automatic Certificate Management Environment) responses.&lt;br /&gt;
&lt;br /&gt;
==== ACME responses ====&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/acme.inc|&amp;lt;nowiki&amp;gt;location /.well-known/acme-challenge {&lt;br /&gt;
    alias /var/www/acme;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
And add this to your proxy configuration:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Automatic generation of certificates ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
{{Cat|/etc/periodic/weekly/acme-client|&amp;lt;nowiki&amp;gt;#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for host in $hosts; do&lt;br /&gt;
        acme-client -a https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf -Nnmv $host &amp;amp;&amp;amp; renew=1&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
[ &amp;quot;$renew&amp;quot; = 1 ] &amp;amp;&amp;amp; rc-service nginx reload&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Make it executable:&lt;br /&gt;
 chmod +x /etc/periodic/weekly/acme-client&lt;br /&gt;
&lt;br /&gt;
This script will run weekly to verify whether one of your certificates is outdated and renew them when needed.&lt;br /&gt;
&lt;br /&gt;
If you have several domains, you can add them to the &#039;&#039;&#039;hosts=&#039;&#039;&#039; variable with a space between each domain. This will create a separate certificate and key for each:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org example.com foo.org bar.io&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Initial generation of keys and certificates ====&lt;br /&gt;
&lt;br /&gt;
To create your initial certificates and keys, you have to run this manually the first time:&lt;br /&gt;
&lt;br /&gt;
 {{Cmd|/etc/periodic/weekly/acme-client}}&lt;br /&gt;
&lt;br /&gt;
Watch the output and see if all goes well. When it&#039;s finished, you should have files in:&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/alpinelinux.nl/fullchain.pem&lt;br /&gt;
 /etc/ssl/acme/private/alpinelinux.org/privkey.pem&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Per site HTTPS configuration ====&lt;br /&gt;
&lt;br /&gt;
Add the following below the previous HTTP configuration:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Redirect HTTP to HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Shared configuration ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/redirect_http.inc|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
location / {&lt;br /&gt;
        return 301 https://$host$request_uri;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Update host configuration ====&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
    include       conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Complete host example with IPv6 support ===&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  80;&lt;br /&gt;
    listen                  [::]:80;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    include                 conf.d/acme.inc;&lt;br /&gt;
    include                 conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    listen                  [::]:443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14190</id>
		<title>Nginx as reverse proxy with acme (letsencrypt)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14190"/>
		<updated>2017-12-09T07:26:13Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* NGINX HTTP */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This setup will allow you to have multiple servers/containers accessible via a single IP address with the added benefit of a centralized generation of [https://letsencrypt.org/ letsencrypt] certificates and secure https (according to &#039;&#039;&#039;ssllabs ssltest&#039;&#039;&#039;). Be aware that you first need to setup a regular HTTP server in order to be able to generate your HTTPS certificates and keys. After you have generated them, you can then add your HTTPS host based configuration.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
For this howto, we need three tools: [[Nginx|NGINX]], {{pkg|acme-client}} and {{pkg|libressl}} (to generate [https://wiki.openssl.org/index.php/Diffie-Hellman_parameters Diffie–Hellman Parameters]).&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add nginx acme-client libressl}}&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTP ===&lt;br /&gt;
&lt;br /&gt;
==== Global configuration ====&lt;br /&gt;
&lt;br /&gt;
First step is to refactor our global &amp;lt;code&amp;gt;nginx.conf&amp;lt;/code&amp;gt;. Its target at a low traffic http server, to increase performance make changes at top level.&lt;br /&gt;
&lt;br /&gt;
The security settings are taken from https://cipherli.st. Please also read https://hstspreload.org for details about HSTS.&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/nginx.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
# /etc/nginx/nginx.conf&lt;br /&gt;
&lt;br /&gt;
user  nginx;&lt;br /&gt;
&lt;br /&gt;
worker_processes  1; # use &amp;quot;auto&amp;quot; to use all available cores (high performance)&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections  1024; # increase if you need more connections&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    # server_names_hash_bucket_size controls the maximum length&lt;br /&gt;
    # of a virtual host entry (ie the length of the domain name).&lt;br /&gt;
    server_names_hash_bucket_size   64;&lt;br /&gt;
    server_tokens                   off; # hide who we are&lt;br /&gt;
    sendfile                        off; # can cause issues&lt;br /&gt;
&lt;br /&gt;
    # secure nginx according to https://cipherli.st/&lt;br /&gt;
    #ssl_protocols TLSv1.3; # Requires nginx &amp;gt;= 1.13.0 else use TLSv1.2&lt;br /&gt;
    ssl_protocols TLSv1.2; # We use TLSv1.2 because current stable nginx release don&#039;t support TLSv1.3&lt;br /&gt;
    ssl_prefer_server_ciphers on;&lt;br /&gt;
    ssl_dhparam /etc/nginx/dhparam.pem; # openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096&lt;br /&gt;
    ssl_ciphers &amp;quot;EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH&amp;quot;;&lt;br /&gt;
    ssl_ecdh_curve secp384r1; # Requires nginx &amp;gt;= 1.1.0&lt;br /&gt;
    ssl_session_cache shared:SSL:10m;&lt;br /&gt;
    ssl_session_tickets off; # Requires nginx &amp;gt;= 1.5.9&lt;br /&gt;
    ssl_stapling on; # Requires nginx &amp;gt;= 1.3.7&lt;br /&gt;
    ssl_stapling_verify on; # Requires nginx =&amp;gt; 1.3.7&lt;br /&gt;
    resolver 8.8.8.8 8.8.4.4 valid=300s;&lt;br /&gt;
    resolver_timeout 5s;&lt;br /&gt;
    add_header Strict-Transport-Security &amp;quot;max-age=63072000&amp;quot;; # https://hstspreload.org&lt;br /&gt;
    add_header X-Frame-Options DENY;&lt;br /&gt;
    add_header X-Content-Type-Options nosniff;&lt;br /&gt;
    add_header X-XSS-Protection &amp;quot;1; mode=block&amp;quot;;&lt;br /&gt;
    add_header X-Robots-Tag none; &lt;br /&gt;
&lt;br /&gt;
    # nginx will find this file in the config directory set at nginx build time&lt;br /&gt;
    include mime.types;&lt;br /&gt;
&lt;br /&gt;
    #fallback in case we can&#039;t determine a type&lt;br /&gt;
    default_type application/octet-stream;&lt;br /&gt;
&lt;br /&gt;
    # buffering causes issues&lt;br /&gt;
    proxy_buffering off;&lt;br /&gt;
&lt;br /&gt;
    # include hosts&lt;br /&gt;
    include conf.d/*.conf;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Diffie–Hellman Parameters ====&lt;br /&gt;
&lt;br /&gt;
In the above configuration &amp;lt;var&amp;gt;ssl_dhparam&amp;lt;/var&amp;gt; is used, so we need to generate a global &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file. We want to use a 4096 key size, but this can take a very long time. Because of this, we are adding an extra option (&amp;lt;var&amp;gt;dsaparam&amp;lt;/var&amp;gt;) to generate our &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file (see [https://wiki.openssl.org/index.php/Manual:Dhparam(1)#OPTIONS this] wiki section):&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096}}&lt;br /&gt;
&lt;br /&gt;
At this point, you should be able to (re)start your nginx server, but it will not use any of the security features yet.&lt;br /&gt;
&lt;br /&gt;
==== Per site configuration files (conf.d) ====&lt;br /&gt;
&lt;br /&gt;
Since Alpine v3.5, we ship &#039;&#039;&#039;NGINX&#039;&#039;&#039; with a &amp;lt;code&amp;gt;default.conf&amp;lt;/code&amp;gt; within the {{path|/etc/nginx/conf.d}} directory.&lt;br /&gt;
&lt;br /&gt;
To add support for another website, you can add files with the &#039;&#039;&#039;.conf&#039;&#039;&#039; extension to this directory:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Common configuration includes ====&lt;br /&gt;
&lt;br /&gt;
If you need to setup multiple proxy setups, you can include duplicated data such as shown below:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/proxy_set_header.inc|&amp;lt;nowiki&amp;gt;proxy_set_header    X-Forwarded-By       $server_addr:$server_port;&lt;br /&gt;
proxy_set_header    X-Forwarded-For      $remote_addr;&lt;br /&gt;
proxy_set_header    X-Forwarded-Proto    $scheme;&lt;br /&gt;
proxy_set_header    Host                 $host;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== acme-client ===&lt;br /&gt;
&lt;br /&gt;
To allow &#039;&#039;&#039;NGINX&#039;&#039;&#039; to support https, we need to add certificates and support for ACME (Automatic Certificate Management Environment) responses.&lt;br /&gt;
&lt;br /&gt;
==== ACME responses ====&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/acme.inc|&amp;lt;nowiki&amp;gt;location /.well-known/acme-challenge {&lt;br /&gt;
    alias /var/www/acme;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
And add this to your proxy configuration:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Automatic generation of certificates ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
{{Cat|/etc/periodic/weekly/acme-client|&amp;lt;nowiki&amp;gt;#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for host in $hosts; do&lt;br /&gt;
        acme-client -a https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf -Nnmv $host &amp;amp;&amp;amp; renew=1&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
[ &amp;quot;$renew&amp;quot; = 1 ] &amp;amp;&amp;amp; rc-service nginx reload&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Make it executable:&lt;br /&gt;
 chmod +x /etc/periodic/weekly/acme-client&lt;br /&gt;
&lt;br /&gt;
This script will run weekly to verify whether one of your certificates is outdated and renew them when needed.&lt;br /&gt;
&lt;br /&gt;
If you have several domains, you can add them to the &#039;&#039;&#039;hosts=&#039;&#039;&#039; variable with a space between each domain. This will create a separate certificate and key for each:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org example.com foo.org bar.io&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Initial generation of keys and certificates ====&lt;br /&gt;
&lt;br /&gt;
To create your initial certificates and keys, you have to run this manually the first time:&lt;br /&gt;
&lt;br /&gt;
 {{Cmd|/etc/periodic/weekly/acme-client}}&lt;br /&gt;
&lt;br /&gt;
Watch the output and see if all goes well. When it&#039;s finished, you should have files in:&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/alpinelinux.nl/fullchain.pem&lt;br /&gt;
 /etc/ssl/acme/private/alpinelinux.org/privkey.pem&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Per site HTTPS configuration ====&lt;br /&gt;
&lt;br /&gt;
Add the following below the previous HTTP configuration:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Redirect HTTP to HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Shared configuration ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/redirect_http.inc|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
location / {&lt;br /&gt;
        return 301 https://$host$request_uri;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Update host configuration ====&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
    include       conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Complete host example with IPv6 support ===&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  80;&lt;br /&gt;
    listen                  [::]:80;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    include                 conf.d/acme.inc;&lt;br /&gt;
    include                 conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    listen                  [::]:443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14189</id>
		<title>Nginx as reverse proxy with acme (letsencrypt)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14189"/>
		<updated>2017-12-09T07:16:02Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* Common configuration includes */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This setup will allow you to have multiple servers/containers accessible via a single IP address with the added benefit of a centralized generation of [https://letsencrypt.org/ letsencrypt] certificates and secure https (according to &#039;&#039;&#039;ssllabs ssltest&#039;&#039;&#039;). Be aware that you first need to setup a regular HTTP server in order to be able to generate your HTTPS certificates and keys. After you have generated them, you can then add your HTTPS host based configuration.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
For this howto, we need three tools: [[Nginx|NGINX]], {{pkg|acme-client}} and {{pkg|libressl}} (to generate [https://wiki.openssl.org/index.php/Diffie-Hellman_parameters Diffie–Hellman Parameters]).&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add nginx acme-client libressl}}&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTP ===&lt;br /&gt;
&lt;br /&gt;
==== Global configuration ====&lt;br /&gt;
&lt;br /&gt;
First step is to refactor our global &amp;lt;code&amp;gt;nginx.conf&amp;lt;/code&amp;gt;. Its target at a low traffic http server, to increase performance make changes at top level.&lt;br /&gt;
&lt;br /&gt;
The security settings are taken from https://cipherli.st. Please also read https://hstspreload.org for details about HSTS.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ngnix configuration file&lt;br /&gt;
&lt;br /&gt;
user  nginx;&lt;br /&gt;
&lt;br /&gt;
worker_processes  1; # use &amp;quot;auto&amp;quot; to use all available cores (high performance)&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections  1024; # increase if you need more connections&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    # server_names_hash_bucket_size controls the maximum length&lt;br /&gt;
    # of a virtual host entry (ie the length of the domain name).&lt;br /&gt;
    server_names_hash_bucket_size   64;&lt;br /&gt;
    server_tokens                   off; # hide who we are&lt;br /&gt;
    sendfile                        off; # can cause issues&lt;br /&gt;
&lt;br /&gt;
    # secure nginx according to https://cipherli.st/&lt;br /&gt;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;&lt;br /&gt;
    ssl_prefer_server_ciphers on;&lt;br /&gt;
    ssl_ciphers &amp;quot;EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH&amp;quot;;&lt;br /&gt;
    ssl_ecdh_curve secp384r1; # Requires nginx &amp;gt;= 1.1.0&lt;br /&gt;
    ssl_session_cache shared:SSL:10m;&lt;br /&gt;
    ssl_session_tickets off; # Requires nginx &amp;gt;= 1.5.9&lt;br /&gt;
    ssl_stapling on; # Requires nginx &amp;gt;= 1.3.7&lt;br /&gt;
    ssl_stapling_verify on; # Requires nginx =&amp;gt; 1.3.7&lt;br /&gt;
    resolver 8.8.8.8 8.8.4.4 valid=300s;&lt;br /&gt;
    resolver_timeout 5s;&lt;br /&gt;
    add_header Strict-Transport-Security &amp;quot;max-age=63072000&amp;quot;; # https://hstspreload.org&lt;br /&gt;
    add_header X-Frame-Options DENY;&lt;br /&gt;
    add_header X-Content-Type-Options nosniff;&lt;br /&gt;
&lt;br /&gt;
    ssl_dhparam dhparam.pem;&lt;br /&gt;
&lt;br /&gt;
    # nginx will find this file in the config directory set at nginx build time&lt;br /&gt;
    include mime.types;&lt;br /&gt;
&lt;br /&gt;
    #fallback in case we can&#039;t determine a type&lt;br /&gt;
    default_type application/octet-stream;&lt;br /&gt;
&lt;br /&gt;
    # buffering causes issues&lt;br /&gt;
    proxy_buffering off;&lt;br /&gt;
&lt;br /&gt;
    # include hosts&lt;br /&gt;
    include conf.d/*.conf;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Diffie–Hellman Parameters ====&lt;br /&gt;
&lt;br /&gt;
In the above configuration &amp;lt;var&amp;gt;ssl_dhparam&amp;lt;/var&amp;gt; is used, so we need to generate a global &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file. We want to use a 4096 key size, but this can take a very long time. Because of this, we are adding an extra option (&amp;lt;var&amp;gt;dsaparam&amp;lt;/var&amp;gt;) to generate our &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file (see [https://wiki.openssl.org/index.php/Manual:Dhparam(1)#OPTIONS this] wiki section):&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096}}&lt;br /&gt;
&lt;br /&gt;
At this point, you should be able to (re)start your nginx server, but it will not use any of the security features yet.&lt;br /&gt;
&lt;br /&gt;
==== Per site configuration files (conf.d) ====&lt;br /&gt;
&lt;br /&gt;
Since Alpine v3.5, we ship &#039;&#039;&#039;NGINX&#039;&#039;&#039; with a &amp;lt;code&amp;gt;default.conf&amp;lt;/code&amp;gt; within the {{path|/etc/nginx/conf.d}} directory.&lt;br /&gt;
&lt;br /&gt;
To add support for another website, you can add files with the &#039;&#039;&#039;.conf&#039;&#039;&#039; extension to this directory:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Common configuration includes ====&lt;br /&gt;
&lt;br /&gt;
If you need to setup multiple proxy setups, you can include duplicated data such as shown below:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/proxy_set_header.inc|&amp;lt;nowiki&amp;gt;proxy_set_header    X-Forwarded-By       $server_addr:$server_port;&lt;br /&gt;
proxy_set_header    X-Forwarded-For      $remote_addr;&lt;br /&gt;
proxy_set_header    X-Forwarded-Proto    $scheme;&lt;br /&gt;
proxy_set_header    Host                 $host;&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== acme-client ===&lt;br /&gt;
&lt;br /&gt;
To allow &#039;&#039;&#039;NGINX&#039;&#039;&#039; to support https, we need to add certificates and support for ACME (Automatic Certificate Management Environment) responses.&lt;br /&gt;
&lt;br /&gt;
==== ACME responses ====&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/acme.inc|&amp;lt;nowiki&amp;gt;location /.well-known/acme-challenge {&lt;br /&gt;
    alias /var/www/acme;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
And add this to your proxy configuration:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Automatic generation of certificates ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
{{Cat|/etc/periodic/weekly/acme-client|&amp;lt;nowiki&amp;gt;#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for host in $hosts; do&lt;br /&gt;
        acme-client -a https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf -Nnmv $host &amp;amp;&amp;amp; renew=1&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
[ &amp;quot;$renew&amp;quot; = 1 ] &amp;amp;&amp;amp; rc-service nginx reload&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Make it executable:&lt;br /&gt;
 chmod +x /etc/periodic/weekly/acme-client&lt;br /&gt;
&lt;br /&gt;
This script will run weekly to verify whether one of your certificates is outdated and renew them when needed.&lt;br /&gt;
&lt;br /&gt;
If you have several domains, you can add them to the &#039;&#039;&#039;hosts=&#039;&#039;&#039; variable with a space between each domain. This will create a separate certificate and key for each:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org example.com foo.org bar.io&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Initial generation of keys and certificates ====&lt;br /&gt;
&lt;br /&gt;
To create your initial certificates and keys, you have to run this manually the first time:&lt;br /&gt;
&lt;br /&gt;
 {{Cmd|/etc/periodic/weekly/acme-client}}&lt;br /&gt;
&lt;br /&gt;
Watch the output and see if all goes well. When it&#039;s finished, you should have files in:&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/alpinelinux.nl/fullchain.pem&lt;br /&gt;
 /etc/ssl/acme/private/alpinelinux.org/privkey.pem&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Per site HTTPS configuration ====&lt;br /&gt;
&lt;br /&gt;
Add the following below the previous HTTP configuration:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Redirect HTTP to HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Shared configuration ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/redirect_http.inc|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
location / {&lt;br /&gt;
        return 301 https://$host$request_uri;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Update host configuration ====&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
    include       conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Complete host example with IPv6 support ===&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  80;&lt;br /&gt;
    listen                  [::]:80;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    include                 conf.d/acme.inc;&lt;br /&gt;
    include                 conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    listen                  [::]:443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14188</id>
		<title>Nginx as reverse proxy with acme (letsencrypt)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14188"/>
		<updated>2017-12-09T07:15:29Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* acme-client */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This setup will allow you to have multiple servers/containers accessible via a single IP address with the added benefit of a centralized generation of [https://letsencrypt.org/ letsencrypt] certificates and secure https (according to &#039;&#039;&#039;ssllabs ssltest&#039;&#039;&#039;). Be aware that you first need to setup a regular HTTP server in order to be able to generate your HTTPS certificates and keys. After you have generated them, you can then add your HTTPS host based configuration.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
For this howto, we need three tools: [[Nginx|NGINX]], {{pkg|acme-client}} and {{pkg|libressl}} (to generate [https://wiki.openssl.org/index.php/Diffie-Hellman_parameters Diffie–Hellman Parameters]).&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add nginx acme-client libressl}}&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTP ===&lt;br /&gt;
&lt;br /&gt;
==== Global configuration ====&lt;br /&gt;
&lt;br /&gt;
First step is to refactor our global &amp;lt;code&amp;gt;nginx.conf&amp;lt;/code&amp;gt;. Its target at a low traffic http server, to increase performance make changes at top level.&lt;br /&gt;
&lt;br /&gt;
The security settings are taken from https://cipherli.st. Please also read https://hstspreload.org for details about HSTS.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ngnix configuration file&lt;br /&gt;
&lt;br /&gt;
user  nginx;&lt;br /&gt;
&lt;br /&gt;
worker_processes  1; # use &amp;quot;auto&amp;quot; to use all available cores (high performance)&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections  1024; # increase if you need more connections&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    # server_names_hash_bucket_size controls the maximum length&lt;br /&gt;
    # of a virtual host entry (ie the length of the domain name).&lt;br /&gt;
    server_names_hash_bucket_size   64;&lt;br /&gt;
    server_tokens                   off; # hide who we are&lt;br /&gt;
    sendfile                        off; # can cause issues&lt;br /&gt;
&lt;br /&gt;
    # secure nginx according to https://cipherli.st/&lt;br /&gt;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;&lt;br /&gt;
    ssl_prefer_server_ciphers on;&lt;br /&gt;
    ssl_ciphers &amp;quot;EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH&amp;quot;;&lt;br /&gt;
    ssl_ecdh_curve secp384r1; # Requires nginx &amp;gt;= 1.1.0&lt;br /&gt;
    ssl_session_cache shared:SSL:10m;&lt;br /&gt;
    ssl_session_tickets off; # Requires nginx &amp;gt;= 1.5.9&lt;br /&gt;
    ssl_stapling on; # Requires nginx &amp;gt;= 1.3.7&lt;br /&gt;
    ssl_stapling_verify on; # Requires nginx =&amp;gt; 1.3.7&lt;br /&gt;
    resolver 8.8.8.8 8.8.4.4 valid=300s;&lt;br /&gt;
    resolver_timeout 5s;&lt;br /&gt;
    add_header Strict-Transport-Security &amp;quot;max-age=63072000&amp;quot;; # https://hstspreload.org&lt;br /&gt;
    add_header X-Frame-Options DENY;&lt;br /&gt;
    add_header X-Content-Type-Options nosniff;&lt;br /&gt;
&lt;br /&gt;
    ssl_dhparam dhparam.pem;&lt;br /&gt;
&lt;br /&gt;
    # nginx will find this file in the config directory set at nginx build time&lt;br /&gt;
    include mime.types;&lt;br /&gt;
&lt;br /&gt;
    #fallback in case we can&#039;t determine a type&lt;br /&gt;
    default_type application/octet-stream;&lt;br /&gt;
&lt;br /&gt;
    # buffering causes issues&lt;br /&gt;
    proxy_buffering off;&lt;br /&gt;
&lt;br /&gt;
    # include hosts&lt;br /&gt;
    include conf.d/*.conf;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Diffie–Hellman Parameters ====&lt;br /&gt;
&lt;br /&gt;
In the above configuration &amp;lt;var&amp;gt;ssl_dhparam&amp;lt;/var&amp;gt; is used, so we need to generate a global &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file. We want to use a 4096 key size, but this can take a very long time. Because of this, we are adding an extra option (&amp;lt;var&amp;gt;dsaparam&amp;lt;/var&amp;gt;) to generate our &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file (see [https://wiki.openssl.org/index.php/Manual:Dhparam(1)#OPTIONS this] wiki section):&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096}}&lt;br /&gt;
&lt;br /&gt;
At this point, you should be able to (re)start your nginx server, but it will not use any of the security features yet.&lt;br /&gt;
&lt;br /&gt;
==== Per site configuration files (conf.d) ====&lt;br /&gt;
&lt;br /&gt;
Since Alpine v3.5, we ship &#039;&#039;&#039;NGINX&#039;&#039;&#039; with a &amp;lt;code&amp;gt;default.conf&amp;lt;/code&amp;gt; within the {{path|/etc/nginx/conf.d}} directory.&lt;br /&gt;
&lt;br /&gt;
To add support for another website, you can add files with the &#039;&#039;&#039;.conf&#039;&#039;&#039; extension to this directory:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Common configuration includes ====&lt;br /&gt;
&lt;br /&gt;
If you need to setup multiple proxy setups, you can include duplicated data such as shown below:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/proxy_set_header.inc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
proxy_set_header    X-Forwarded-By       $server_addr:$server_port;&lt;br /&gt;
proxy_set_header    X-Forwarded-For      $remote_addr;&lt;br /&gt;
proxy_set_header    X-Forwarded-Proto    $scheme;&lt;br /&gt;
proxy_set_header    Host                 $host;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== acme-client ===&lt;br /&gt;
&lt;br /&gt;
To allow &#039;&#039;&#039;NGINX&#039;&#039;&#039; to support https, we need to add certificates and support for ACME (Automatic Certificate Management Environment) responses.&lt;br /&gt;
&lt;br /&gt;
==== ACME responses ====&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/acme.inc|&amp;lt;nowiki&amp;gt;location /.well-known/acme-challenge {&lt;br /&gt;
    alias /var/www/acme;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
And add this to your proxy configuration:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Automatic generation of certificates ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
{{Cat|/etc/periodic/weekly/acme-client|&amp;lt;nowiki&amp;gt;#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for host in $hosts; do&lt;br /&gt;
        acme-client -a https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf -Nnmv $host &amp;amp;&amp;amp; renew=1&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
[ &amp;quot;$renew&amp;quot; = 1 ] &amp;amp;&amp;amp; rc-service nginx reload&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Make it executable:&lt;br /&gt;
 chmod +x /etc/periodic/weekly/acme-client&lt;br /&gt;
&lt;br /&gt;
This script will run weekly to verify whether one of your certificates is outdated and renew them when needed.&lt;br /&gt;
&lt;br /&gt;
If you have several domains, you can add them to the &#039;&#039;&#039;hosts=&#039;&#039;&#039; variable with a space between each domain. This will create a separate certificate and key for each:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org example.com foo.org bar.io&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Initial generation of keys and certificates ====&lt;br /&gt;
&lt;br /&gt;
To create your initial certificates and keys, you have to run this manually the first time:&lt;br /&gt;
&lt;br /&gt;
 {{Cmd|/etc/periodic/weekly/acme-client}}&lt;br /&gt;
&lt;br /&gt;
Watch the output and see if all goes well. When it&#039;s finished, you should have files in:&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/alpinelinux.nl/fullchain.pem&lt;br /&gt;
 /etc/ssl/acme/private/alpinelinux.org/privkey.pem&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Per site HTTPS configuration ====&lt;br /&gt;
&lt;br /&gt;
Add the following below the previous HTTP configuration:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Redirect HTTP to HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Shared configuration ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/redirect_http.inc|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
location / {&lt;br /&gt;
        return 301 https://$host$request_uri;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Update host configuration ====&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
    include       conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Complete host example with IPv6 support ===&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  80;&lt;br /&gt;
    listen                  [::]:80;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    include                 conf.d/acme.inc;&lt;br /&gt;
    include                 conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    listen                  [::]:443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14187</id>
		<title>Nginx as reverse proxy with acme (letsencrypt)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14187"/>
		<updated>2017-12-09T07:14:02Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* Per site HTTPS configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This setup will allow you to have multiple servers/containers accessible via a single IP address with the added benefit of a centralized generation of [https://letsencrypt.org/ letsencrypt] certificates and secure https (according to &#039;&#039;&#039;ssllabs ssltest&#039;&#039;&#039;). Be aware that you first need to setup a regular HTTP server in order to be able to generate your HTTPS certificates and keys. After you have generated them, you can then add your HTTPS host based configuration.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
For this howto, we need three tools: [[Nginx|NGINX]], {{pkg|acme-client}} and {{pkg|libressl}} (to generate [https://wiki.openssl.org/index.php/Diffie-Hellman_parameters Diffie–Hellman Parameters]).&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add nginx acme-client libressl}}&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTP ===&lt;br /&gt;
&lt;br /&gt;
==== Global configuration ====&lt;br /&gt;
&lt;br /&gt;
First step is to refactor our global &amp;lt;code&amp;gt;nginx.conf&amp;lt;/code&amp;gt;. Its target at a low traffic http server, to increase performance make changes at top level.&lt;br /&gt;
&lt;br /&gt;
The security settings are taken from https://cipherli.st. Please also read https://hstspreload.org for details about HSTS.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ngnix configuration file&lt;br /&gt;
&lt;br /&gt;
user  nginx;&lt;br /&gt;
&lt;br /&gt;
worker_processes  1; # use &amp;quot;auto&amp;quot; to use all available cores (high performance)&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections  1024; # increase if you need more connections&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    # server_names_hash_bucket_size controls the maximum length&lt;br /&gt;
    # of a virtual host entry (ie the length of the domain name).&lt;br /&gt;
    server_names_hash_bucket_size   64;&lt;br /&gt;
    server_tokens                   off; # hide who we are&lt;br /&gt;
    sendfile                        off; # can cause issues&lt;br /&gt;
&lt;br /&gt;
    # secure nginx according to https://cipherli.st/&lt;br /&gt;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;&lt;br /&gt;
    ssl_prefer_server_ciphers on;&lt;br /&gt;
    ssl_ciphers &amp;quot;EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH&amp;quot;;&lt;br /&gt;
    ssl_ecdh_curve secp384r1; # Requires nginx &amp;gt;= 1.1.0&lt;br /&gt;
    ssl_session_cache shared:SSL:10m;&lt;br /&gt;
    ssl_session_tickets off; # Requires nginx &amp;gt;= 1.5.9&lt;br /&gt;
    ssl_stapling on; # Requires nginx &amp;gt;= 1.3.7&lt;br /&gt;
    ssl_stapling_verify on; # Requires nginx =&amp;gt; 1.3.7&lt;br /&gt;
    resolver 8.8.8.8 8.8.4.4 valid=300s;&lt;br /&gt;
    resolver_timeout 5s;&lt;br /&gt;
    add_header Strict-Transport-Security &amp;quot;max-age=63072000&amp;quot;; # https://hstspreload.org&lt;br /&gt;
    add_header X-Frame-Options DENY;&lt;br /&gt;
    add_header X-Content-Type-Options nosniff;&lt;br /&gt;
&lt;br /&gt;
    ssl_dhparam dhparam.pem;&lt;br /&gt;
&lt;br /&gt;
    # nginx will find this file in the config directory set at nginx build time&lt;br /&gt;
    include mime.types;&lt;br /&gt;
&lt;br /&gt;
    #fallback in case we can&#039;t determine a type&lt;br /&gt;
    default_type application/octet-stream;&lt;br /&gt;
&lt;br /&gt;
    # buffering causes issues&lt;br /&gt;
    proxy_buffering off;&lt;br /&gt;
&lt;br /&gt;
    # include hosts&lt;br /&gt;
    include conf.d/*.conf;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Diffie–Hellman Parameters ====&lt;br /&gt;
&lt;br /&gt;
In the above configuration &amp;lt;var&amp;gt;ssl_dhparam&amp;lt;/var&amp;gt; is used, so we need to generate a global &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file. We want to use a 4096 key size, but this can take a very long time. Because of this, we are adding an extra option (&amp;lt;var&amp;gt;dsaparam&amp;lt;/var&amp;gt;) to generate our &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file (see [https://wiki.openssl.org/index.php/Manual:Dhparam(1)#OPTIONS this] wiki section):&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096}}&lt;br /&gt;
&lt;br /&gt;
At this point, you should be able to (re)start your nginx server, but it will not use any of the security features yet.&lt;br /&gt;
&lt;br /&gt;
==== Per site configuration files (conf.d) ====&lt;br /&gt;
&lt;br /&gt;
Since Alpine v3.5, we ship &#039;&#039;&#039;NGINX&#039;&#039;&#039; with a &amp;lt;code&amp;gt;default.conf&amp;lt;/code&amp;gt; within the {{path|/etc/nginx/conf.d}} directory.&lt;br /&gt;
&lt;br /&gt;
To add support for another website, you can add files with the &#039;&#039;&#039;.conf&#039;&#039;&#039; extension to this directory:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Common configuration includes ====&lt;br /&gt;
&lt;br /&gt;
If you need to setup multiple proxy setups, you can include duplicated data such as shown below:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/proxy_set_header.inc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
proxy_set_header    X-Forwarded-By       $server_addr:$server_port;&lt;br /&gt;
proxy_set_header    X-Forwarded-For      $remote_addr;&lt;br /&gt;
proxy_set_header    X-Forwarded-Proto    $scheme;&lt;br /&gt;
proxy_set_header    Host                 $host;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== acme-client ===&lt;br /&gt;
&lt;br /&gt;
To allow &#039;&#039;&#039;NGINX&#039;&#039;&#039; to support https, we need to add certificates and support for ACME (Automatic Certificate Management Environment) responses.&lt;br /&gt;
&lt;br /&gt;
==== ACME responses ====&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/acme.inc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
location /.well-known/acme-challenge {&lt;br /&gt;
    alias /var/www/acme;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add this to your proxy configuration:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Automatic generation of certificates ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
{{Cat|/etc/periodic/weekly/acme-client|&amp;lt;nowiki&amp;gt;#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for host in $hosts; do&lt;br /&gt;
        acme-client -a https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf -Nnmv $host &amp;amp;&amp;amp; renew=1&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
[ &amp;quot;$renew&amp;quot; = 1 ] &amp;amp;&amp;amp; rc-service nginx reload&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Make it executable:&lt;br /&gt;
 chmod +x /etc/periodic/weekly/acme-client&lt;br /&gt;
&lt;br /&gt;
This script will run weekly to verify whether one of your certificates is outdated and renew them when needed.&lt;br /&gt;
&lt;br /&gt;
If you have several domains, you can add them to the &#039;&#039;&#039;hosts=&#039;&#039;&#039; variable with a space between each domain. This will create a separate certificate and key for each:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org example.com foo.org bar.io&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Initial generation of keys and certificates ====&lt;br /&gt;
&lt;br /&gt;
To create your initial certificates and keys, you have to run this manually the first time:&lt;br /&gt;
&lt;br /&gt;
 {{Cmd|/etc/periodic/weekly/acme-client}}&lt;br /&gt;
&lt;br /&gt;
Watch the output and see if all goes well. When it&#039;s finished, you should have files in:&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/alpinelinux.nl/fullchain.pem&lt;br /&gt;
 /etc/ssl/acme/private/alpinelinux.org/privkey.pem&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Per site HTTPS configuration ====&lt;br /&gt;
&lt;br /&gt;
Add the following below the previous HTTP configuration:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Redirect HTTP to HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Shared configuration ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/redirect_http.inc|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
location / {&lt;br /&gt;
        return 301 https://$host$request_uri;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Update host configuration ====&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
    include       conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Complete host example with IPv6 support ===&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  80;&lt;br /&gt;
    listen                  [::]:80;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    include                 conf.d/acme.inc;&lt;br /&gt;
    include                 conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    listen                  [::]:443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14186</id>
		<title>Nginx as reverse proxy with acme (letsencrypt)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14186"/>
		<updated>2017-12-09T07:12:54Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* Complete host example with IPv6 support */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This setup will allow you to have multiple servers/containers accessible via a single IP address with the added benefit of a centralized generation of [https://letsencrypt.org/ letsencrypt] certificates and secure https (according to &#039;&#039;&#039;ssllabs ssltest&#039;&#039;&#039;). Be aware that you first need to setup a regular HTTP server in order to be able to generate your HTTPS certificates and keys. After you have generated them, you can then add your HTTPS host based configuration.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
For this howto, we need three tools: [[Nginx|NGINX]], {{pkg|acme-client}} and {{pkg|libressl}} (to generate [https://wiki.openssl.org/index.php/Diffie-Hellman_parameters Diffie–Hellman Parameters]).&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add nginx acme-client libressl}}&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTP ===&lt;br /&gt;
&lt;br /&gt;
==== Global configuration ====&lt;br /&gt;
&lt;br /&gt;
First step is to refactor our global &amp;lt;code&amp;gt;nginx.conf&amp;lt;/code&amp;gt;. Its target at a low traffic http server, to increase performance make changes at top level.&lt;br /&gt;
&lt;br /&gt;
The security settings are taken from https://cipherli.st. Please also read https://hstspreload.org for details about HSTS.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ngnix configuration file&lt;br /&gt;
&lt;br /&gt;
user  nginx;&lt;br /&gt;
&lt;br /&gt;
worker_processes  1; # use &amp;quot;auto&amp;quot; to use all available cores (high performance)&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections  1024; # increase if you need more connections&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    # server_names_hash_bucket_size controls the maximum length&lt;br /&gt;
    # of a virtual host entry (ie the length of the domain name).&lt;br /&gt;
    server_names_hash_bucket_size   64;&lt;br /&gt;
    server_tokens                   off; # hide who we are&lt;br /&gt;
    sendfile                        off; # can cause issues&lt;br /&gt;
&lt;br /&gt;
    # secure nginx according to https://cipherli.st/&lt;br /&gt;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;&lt;br /&gt;
    ssl_prefer_server_ciphers on;&lt;br /&gt;
    ssl_ciphers &amp;quot;EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH&amp;quot;;&lt;br /&gt;
    ssl_ecdh_curve secp384r1; # Requires nginx &amp;gt;= 1.1.0&lt;br /&gt;
    ssl_session_cache shared:SSL:10m;&lt;br /&gt;
    ssl_session_tickets off; # Requires nginx &amp;gt;= 1.5.9&lt;br /&gt;
    ssl_stapling on; # Requires nginx &amp;gt;= 1.3.7&lt;br /&gt;
    ssl_stapling_verify on; # Requires nginx =&amp;gt; 1.3.7&lt;br /&gt;
    resolver 8.8.8.8 8.8.4.4 valid=300s;&lt;br /&gt;
    resolver_timeout 5s;&lt;br /&gt;
    add_header Strict-Transport-Security &amp;quot;max-age=63072000&amp;quot;; # https://hstspreload.org&lt;br /&gt;
    add_header X-Frame-Options DENY;&lt;br /&gt;
    add_header X-Content-Type-Options nosniff;&lt;br /&gt;
&lt;br /&gt;
    ssl_dhparam dhparam.pem;&lt;br /&gt;
&lt;br /&gt;
    # nginx will find this file in the config directory set at nginx build time&lt;br /&gt;
    include mime.types;&lt;br /&gt;
&lt;br /&gt;
    #fallback in case we can&#039;t determine a type&lt;br /&gt;
    default_type application/octet-stream;&lt;br /&gt;
&lt;br /&gt;
    # buffering causes issues&lt;br /&gt;
    proxy_buffering off;&lt;br /&gt;
&lt;br /&gt;
    # include hosts&lt;br /&gt;
    include conf.d/*.conf;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Diffie–Hellman Parameters ====&lt;br /&gt;
&lt;br /&gt;
In the above configuration &amp;lt;var&amp;gt;ssl_dhparam&amp;lt;/var&amp;gt; is used, so we need to generate a global &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file. We want to use a 4096 key size, but this can take a very long time. Because of this, we are adding an extra option (&amp;lt;var&amp;gt;dsaparam&amp;lt;/var&amp;gt;) to generate our &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file (see [https://wiki.openssl.org/index.php/Manual:Dhparam(1)#OPTIONS this] wiki section):&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096}}&lt;br /&gt;
&lt;br /&gt;
At this point, you should be able to (re)start your nginx server, but it will not use any of the security features yet.&lt;br /&gt;
&lt;br /&gt;
==== Per site configuration files (conf.d) ====&lt;br /&gt;
&lt;br /&gt;
Since Alpine v3.5, we ship &#039;&#039;&#039;NGINX&#039;&#039;&#039; with a &amp;lt;code&amp;gt;default.conf&amp;lt;/code&amp;gt; within the {{path|/etc/nginx/conf.d}} directory.&lt;br /&gt;
&lt;br /&gt;
To add support for another website, you can add files with the &#039;&#039;&#039;.conf&#039;&#039;&#039; extension to this directory:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Common configuration includes ====&lt;br /&gt;
&lt;br /&gt;
If you need to setup multiple proxy setups, you can include duplicated data such as shown below:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/proxy_set_header.inc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
proxy_set_header    X-Forwarded-By       $server_addr:$server_port;&lt;br /&gt;
proxy_set_header    X-Forwarded-For      $remote_addr;&lt;br /&gt;
proxy_set_header    X-Forwarded-Proto    $scheme;&lt;br /&gt;
proxy_set_header    Host                 $host;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== acme-client ===&lt;br /&gt;
&lt;br /&gt;
To allow &#039;&#039;&#039;NGINX&#039;&#039;&#039; to support https, we need to add certificates and support for ACME (Automatic Certificate Management Environment) responses.&lt;br /&gt;
&lt;br /&gt;
==== ACME responses ====&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/acme.inc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
location /.well-known/acme-challenge {&lt;br /&gt;
    alias /var/www/acme;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add this to your proxy configuration:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Automatic generation of certificates ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
{{Cat|/etc/periodic/weekly/acme-client|&amp;lt;nowiki&amp;gt;#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for host in $hosts; do&lt;br /&gt;
        acme-client -a https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf -Nnmv $host &amp;amp;&amp;amp; renew=1&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
[ &amp;quot;$renew&amp;quot; = 1 ] &amp;amp;&amp;amp; rc-service nginx reload&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Make it executable:&lt;br /&gt;
 chmod +x /etc/periodic/weekly/acme-client&lt;br /&gt;
&lt;br /&gt;
This script will run weekly to verify whether one of your certificates is outdated and renew them when needed.&lt;br /&gt;
&lt;br /&gt;
If you have several domains, you can add them to the &#039;&#039;&#039;hosts=&#039;&#039;&#039; variable with a space between each domain. This will create a separate certificate and key for each:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org example.com foo.org bar.io&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Initial generation of keys and certificates ====&lt;br /&gt;
&lt;br /&gt;
To create your initial certificates and keys, you have to run this manually the first time:&lt;br /&gt;
&lt;br /&gt;
 {{Cmd|/etc/periodic/weekly/acme-client}}&lt;br /&gt;
&lt;br /&gt;
Watch the output and see if all goes well. When it&#039;s finished, you should have files in:&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/alpinelinux.nl/fullchain.pem&lt;br /&gt;
 /etc/ssl/acme/private/alpinelinux.org/privkey.pem&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Per site HTTPS configuration ====&lt;br /&gt;
&lt;br /&gt;
Add the following below the previous HTTP configuration:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Redirect HTTP to HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Shared configuration ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/redirect_http.inc|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
location / {&lt;br /&gt;
        return 301 https://$host$request_uri;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Update host configuration ====&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
    include       conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Complete host example with IPv6 support ===&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  80;&lt;br /&gt;
    listen                  [::]:80;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    include                 conf.d/acme.inc;&lt;br /&gt;
    include                 conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    listen                  [::]:443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14185</id>
		<title>Nginx as reverse proxy with acme (letsencrypt)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14185"/>
		<updated>2017-12-09T07:11:14Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* Redirect HTTP to HTTPS */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This setup will allow you to have multiple servers/containers accessible via a single IP address with the added benefit of a centralized generation of [https://letsencrypt.org/ letsencrypt] certificates and secure https (according to &#039;&#039;&#039;ssllabs ssltest&#039;&#039;&#039;). Be aware that you first need to setup a regular HTTP server in order to be able to generate your HTTPS certificates and keys. After you have generated them, you can then add your HTTPS host based configuration.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
For this howto, we need three tools: [[Nginx|NGINX]], {{pkg|acme-client}} and {{pkg|libressl}} (to generate [https://wiki.openssl.org/index.php/Diffie-Hellman_parameters Diffie–Hellman Parameters]).&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add nginx acme-client libressl}}&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTP ===&lt;br /&gt;
&lt;br /&gt;
==== Global configuration ====&lt;br /&gt;
&lt;br /&gt;
First step is to refactor our global &amp;lt;code&amp;gt;nginx.conf&amp;lt;/code&amp;gt;. Its target at a low traffic http server, to increase performance make changes at top level.&lt;br /&gt;
&lt;br /&gt;
The security settings are taken from https://cipherli.st. Please also read https://hstspreload.org for details about HSTS.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ngnix configuration file&lt;br /&gt;
&lt;br /&gt;
user  nginx;&lt;br /&gt;
&lt;br /&gt;
worker_processes  1; # use &amp;quot;auto&amp;quot; to use all available cores (high performance)&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections  1024; # increase if you need more connections&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    # server_names_hash_bucket_size controls the maximum length&lt;br /&gt;
    # of a virtual host entry (ie the length of the domain name).&lt;br /&gt;
    server_names_hash_bucket_size   64;&lt;br /&gt;
    server_tokens                   off; # hide who we are&lt;br /&gt;
    sendfile                        off; # can cause issues&lt;br /&gt;
&lt;br /&gt;
    # secure nginx according to https://cipherli.st/&lt;br /&gt;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;&lt;br /&gt;
    ssl_prefer_server_ciphers on;&lt;br /&gt;
    ssl_ciphers &amp;quot;EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH&amp;quot;;&lt;br /&gt;
    ssl_ecdh_curve secp384r1; # Requires nginx &amp;gt;= 1.1.0&lt;br /&gt;
    ssl_session_cache shared:SSL:10m;&lt;br /&gt;
    ssl_session_tickets off; # Requires nginx &amp;gt;= 1.5.9&lt;br /&gt;
    ssl_stapling on; # Requires nginx &amp;gt;= 1.3.7&lt;br /&gt;
    ssl_stapling_verify on; # Requires nginx =&amp;gt; 1.3.7&lt;br /&gt;
    resolver 8.8.8.8 8.8.4.4 valid=300s;&lt;br /&gt;
    resolver_timeout 5s;&lt;br /&gt;
    add_header Strict-Transport-Security &amp;quot;max-age=63072000&amp;quot;; # https://hstspreload.org&lt;br /&gt;
    add_header X-Frame-Options DENY;&lt;br /&gt;
    add_header X-Content-Type-Options nosniff;&lt;br /&gt;
&lt;br /&gt;
    ssl_dhparam dhparam.pem;&lt;br /&gt;
&lt;br /&gt;
    # nginx will find this file in the config directory set at nginx build time&lt;br /&gt;
    include mime.types;&lt;br /&gt;
&lt;br /&gt;
    #fallback in case we can&#039;t determine a type&lt;br /&gt;
    default_type application/octet-stream;&lt;br /&gt;
&lt;br /&gt;
    # buffering causes issues&lt;br /&gt;
    proxy_buffering off;&lt;br /&gt;
&lt;br /&gt;
    # include hosts&lt;br /&gt;
    include conf.d/*.conf;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Diffie–Hellman Parameters ====&lt;br /&gt;
&lt;br /&gt;
In the above configuration &amp;lt;var&amp;gt;ssl_dhparam&amp;lt;/var&amp;gt; is used, so we need to generate a global &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file. We want to use a 4096 key size, but this can take a very long time. Because of this, we are adding an extra option (&amp;lt;var&amp;gt;dsaparam&amp;lt;/var&amp;gt;) to generate our &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file (see [https://wiki.openssl.org/index.php/Manual:Dhparam(1)#OPTIONS this] wiki section):&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096}}&lt;br /&gt;
&lt;br /&gt;
At this point, you should be able to (re)start your nginx server, but it will not use any of the security features yet.&lt;br /&gt;
&lt;br /&gt;
==== Per site configuration files (conf.d) ====&lt;br /&gt;
&lt;br /&gt;
Since Alpine v3.5, we ship &#039;&#039;&#039;NGINX&#039;&#039;&#039; with a &amp;lt;code&amp;gt;default.conf&amp;lt;/code&amp;gt; within the {{path|/etc/nginx/conf.d}} directory.&lt;br /&gt;
&lt;br /&gt;
To add support for another website, you can add files with the &#039;&#039;&#039;.conf&#039;&#039;&#039; extension to this directory:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Common configuration includes ====&lt;br /&gt;
&lt;br /&gt;
If you need to setup multiple proxy setups, you can include duplicated data such as shown below:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/proxy_set_header.inc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
proxy_set_header    X-Forwarded-By       $server_addr:$server_port;&lt;br /&gt;
proxy_set_header    X-Forwarded-For      $remote_addr;&lt;br /&gt;
proxy_set_header    X-Forwarded-Proto    $scheme;&lt;br /&gt;
proxy_set_header    Host                 $host;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== acme-client ===&lt;br /&gt;
&lt;br /&gt;
To allow &#039;&#039;&#039;NGINX&#039;&#039;&#039; to support https, we need to add certificates and support for ACME (Automatic Certificate Management Environment) responses.&lt;br /&gt;
&lt;br /&gt;
==== ACME responses ====&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/acme.inc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
location /.well-known/acme-challenge {&lt;br /&gt;
    alias /var/www/acme;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add this to your proxy configuration:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Automatic generation of certificates ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
{{Cat|/etc/periodic/weekly/acme-client|&amp;lt;nowiki&amp;gt;#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for host in $hosts; do&lt;br /&gt;
        acme-client -a https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf -Nnmv $host &amp;amp;&amp;amp; renew=1&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
[ &amp;quot;$renew&amp;quot; = 1 ] &amp;amp;&amp;amp; rc-service nginx reload&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Make it executable:&lt;br /&gt;
 chmod +x /etc/periodic/weekly/acme-client&lt;br /&gt;
&lt;br /&gt;
This script will run weekly to verify whether one of your certificates is outdated and renew them when needed.&lt;br /&gt;
&lt;br /&gt;
If you have several domains, you can add them to the &#039;&#039;&#039;hosts=&#039;&#039;&#039; variable with a space between each domain. This will create a separate certificate and key for each:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org example.com foo.org bar.io&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Initial generation of keys and certificates ====&lt;br /&gt;
&lt;br /&gt;
To create your initial certificates and keys, you have to run this manually the first time:&lt;br /&gt;
&lt;br /&gt;
 {{Cmd|/etc/periodic/weekly/acme-client}}&lt;br /&gt;
&lt;br /&gt;
Watch the output and see if all goes well. When it&#039;s finished, you should have files in:&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/alpinelinux.nl/fullchain.pem&lt;br /&gt;
 /etc/ssl/acme/private/alpinelinux.org/privkey.pem&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Per site HTTPS configuration ====&lt;br /&gt;
&lt;br /&gt;
Add the following below the previous HTTP configuration:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Redirect HTTP to HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Shared configuration ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/redirect_http.inc|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
location / {&lt;br /&gt;
        return 301 https://$host$request_uri;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Update host configuration ====&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
    include       conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Complete host example with IPv6 support ===&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# alpinelinux.org&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  80;&lt;br /&gt;
    listen                  [::]:80;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    include                 conf.d/acme.inc;&lt;br /&gt;
    include                 conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    listen                  [::]:443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14184</id>
		<title>Nginx as reverse proxy with acme (letsencrypt)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14184"/>
		<updated>2017-12-09T07:06:34Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* Installation */ Fixed broken link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This setup will allow you to have multiple servers/containers accessible via a single IP address with the added benefit of a centralized generation of [https://letsencrypt.org/ letsencrypt] certificates and secure https (according to &#039;&#039;&#039;ssllabs ssltest&#039;&#039;&#039;). Be aware that you first need to setup a regular HTTP server in order to be able to generate your HTTPS certificates and keys. After you have generated them, you can then add your HTTPS host based configuration.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
For this howto, we need three tools: [[Nginx|NGINX]], {{pkg|acme-client}} and {{pkg|libressl}} (to generate [https://wiki.openssl.org/index.php/Diffie-Hellman_parameters Diffie–Hellman Parameters]).&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add nginx acme-client libressl}}&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTP ===&lt;br /&gt;
&lt;br /&gt;
==== Global configuration ====&lt;br /&gt;
&lt;br /&gt;
First step is to refactor our global &amp;lt;code&amp;gt;nginx.conf&amp;lt;/code&amp;gt;. Its target at a low traffic http server, to increase performance make changes at top level.&lt;br /&gt;
&lt;br /&gt;
The security settings are taken from https://cipherli.st. Please also read https://hstspreload.org for details about HSTS.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ngnix configuration file&lt;br /&gt;
&lt;br /&gt;
user  nginx;&lt;br /&gt;
&lt;br /&gt;
worker_processes  1; # use &amp;quot;auto&amp;quot; to use all available cores (high performance)&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections  1024; # increase if you need more connections&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    # server_names_hash_bucket_size controls the maximum length&lt;br /&gt;
    # of a virtual host entry (ie the length of the domain name).&lt;br /&gt;
    server_names_hash_bucket_size   64;&lt;br /&gt;
    server_tokens                   off; # hide who we are&lt;br /&gt;
    sendfile                        off; # can cause issues&lt;br /&gt;
&lt;br /&gt;
    # secure nginx according to https://cipherli.st/&lt;br /&gt;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;&lt;br /&gt;
    ssl_prefer_server_ciphers on;&lt;br /&gt;
    ssl_ciphers &amp;quot;EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH&amp;quot;;&lt;br /&gt;
    ssl_ecdh_curve secp384r1; # Requires nginx &amp;gt;= 1.1.0&lt;br /&gt;
    ssl_session_cache shared:SSL:10m;&lt;br /&gt;
    ssl_session_tickets off; # Requires nginx &amp;gt;= 1.5.9&lt;br /&gt;
    ssl_stapling on; # Requires nginx &amp;gt;= 1.3.7&lt;br /&gt;
    ssl_stapling_verify on; # Requires nginx =&amp;gt; 1.3.7&lt;br /&gt;
    resolver 8.8.8.8 8.8.4.4 valid=300s;&lt;br /&gt;
    resolver_timeout 5s;&lt;br /&gt;
    add_header Strict-Transport-Security &amp;quot;max-age=63072000&amp;quot;; # https://hstspreload.org&lt;br /&gt;
    add_header X-Frame-Options DENY;&lt;br /&gt;
    add_header X-Content-Type-Options nosniff;&lt;br /&gt;
&lt;br /&gt;
    ssl_dhparam dhparam.pem;&lt;br /&gt;
&lt;br /&gt;
    # nginx will find this file in the config directory set at nginx build time&lt;br /&gt;
    include mime.types;&lt;br /&gt;
&lt;br /&gt;
    #fallback in case we can&#039;t determine a type&lt;br /&gt;
    default_type application/octet-stream;&lt;br /&gt;
&lt;br /&gt;
    # buffering causes issues&lt;br /&gt;
    proxy_buffering off;&lt;br /&gt;
&lt;br /&gt;
    # include hosts&lt;br /&gt;
    include conf.d/*.conf;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Diffie–Hellman Parameters ====&lt;br /&gt;
&lt;br /&gt;
In the above configuration &amp;lt;var&amp;gt;ssl_dhparam&amp;lt;/var&amp;gt; is used, so we need to generate a global &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file. We want to use a 4096 key size, but this can take a very long time. Because of this, we are adding an extra option (&amp;lt;var&amp;gt;dsaparam&amp;lt;/var&amp;gt;) to generate our &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file (see [https://wiki.openssl.org/index.php/Manual:Dhparam(1)#OPTIONS this] wiki section):&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096}}&lt;br /&gt;
&lt;br /&gt;
At this point, you should be able to (re)start your nginx server, but it will not use any of the security features yet.&lt;br /&gt;
&lt;br /&gt;
==== Per site configuration files (conf.d) ====&lt;br /&gt;
&lt;br /&gt;
Since Alpine v3.5, we ship &#039;&#039;&#039;NGINX&#039;&#039;&#039; with a &amp;lt;code&amp;gt;default.conf&amp;lt;/code&amp;gt; within the {{path|/etc/nginx/conf.d}} directory.&lt;br /&gt;
&lt;br /&gt;
To add support for another website, you can add files with the &#039;&#039;&#039;.conf&#039;&#039;&#039; extension to this directory:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Common configuration includes ====&lt;br /&gt;
&lt;br /&gt;
If you need to setup multiple proxy setups, you can include duplicated data such as shown below:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/proxy_set_header.inc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
proxy_set_header    X-Forwarded-By       $server_addr:$server_port;&lt;br /&gt;
proxy_set_header    X-Forwarded-For      $remote_addr;&lt;br /&gt;
proxy_set_header    X-Forwarded-Proto    $scheme;&lt;br /&gt;
proxy_set_header    Host                 $host;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== acme-client ===&lt;br /&gt;
&lt;br /&gt;
To allow &#039;&#039;&#039;NGINX&#039;&#039;&#039; to support https, we need to add certificates and support for ACME (Automatic Certificate Management Environment) responses.&lt;br /&gt;
&lt;br /&gt;
==== ACME responses ====&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/acme.inc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
location /.well-known/acme-challenge {&lt;br /&gt;
    alias /var/www/acme;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add this to your proxy configuration:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Automatic generation of certificates ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
{{Cat|/etc/periodic/weekly/acme-client|&amp;lt;nowiki&amp;gt;#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for host in $hosts; do&lt;br /&gt;
        acme-client -a https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf -Nnmv $host &amp;amp;&amp;amp; renew=1&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
[ &amp;quot;$renew&amp;quot; = 1 ] &amp;amp;&amp;amp; rc-service nginx reload&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Make it executable:&lt;br /&gt;
 chmod +x /etc/periodic/weekly/acme-client&lt;br /&gt;
&lt;br /&gt;
This script will run weekly to verify whether one of your certificates is outdated and renew them when needed.&lt;br /&gt;
&lt;br /&gt;
If you have several domains, you can add them to the &#039;&#039;&#039;hosts=&#039;&#039;&#039; variable with a space between each domain. This will create a separate certificate and key for each:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org example.com foo.org bar.io&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Initial generation of keys and certificates ====&lt;br /&gt;
&lt;br /&gt;
To create your initial certificates and keys, you have to run this manually the first time:&lt;br /&gt;
&lt;br /&gt;
 {{Cmd|/etc/periodic/weekly/acme-client}}&lt;br /&gt;
&lt;br /&gt;
Watch the output and see if all goes well. When it&#039;s finished, you should have files in:&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/alpinelinux.nl/fullchain.pem&lt;br /&gt;
 /etc/ssl/acme/private/alpinelinux.org/privkey.pem&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Per site HTTPS configuration ====&lt;br /&gt;
&lt;br /&gt;
Add the following below the previous HTTP configuration:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Redirect HTTP to HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Shared configuration ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/redirect_http.inc|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
location / {&lt;br /&gt;
        return 301 https://$host$request_uri;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Update host configuration ====&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
    include       conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Complete host example with IPv6 support ===&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# alpinelinux.org&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  80;&lt;br /&gt;
    listen                  [::]:80;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    include                 conf.d/acme.inc;&lt;br /&gt;
    include                 conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    listen                  [::]:443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14183</id>
		<title>Nginx as reverse proxy with acme (letsencrypt)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14183"/>
		<updated>2017-12-08T20:31:39Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: Replaced openssl with libressl&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This setup will allow you to have multiple servers/containers accessible via a single IP address with the added benefit of a centralized generation of [https://letsencrypt.org/ letsencrypt] certificates and secure https (according to &#039;&#039;&#039;ssllabs ssltest&#039;&#039;&#039;). Be aware that you first need to setup a regular HTTP server in order to be able to generate your HTTPS certificates and keys. After you have generated them, you can then add your HTTPS host based configuration.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
For this howto, we need three tools: [[NGINX]], {{pkg|acme-client}} and {{pkg|libressl}} (to generate [https://wiki.openssl.org/index.php/Diffie-Hellman_parameters Diffie–Hellman Parameters]).&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add nginx acme-client libressl}}&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTP ===&lt;br /&gt;
&lt;br /&gt;
==== Global configuration ====&lt;br /&gt;
&lt;br /&gt;
First step is to refactor our global &amp;lt;code&amp;gt;nginx.conf&amp;lt;/code&amp;gt;. Its target at a low traffic http server, to increase performance make changes at top level.&lt;br /&gt;
&lt;br /&gt;
The security settings are taken from https://cipherli.st. Please also read https://hstspreload.org for details about HSTS.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ngnix configuration file&lt;br /&gt;
&lt;br /&gt;
user  nginx;&lt;br /&gt;
&lt;br /&gt;
worker_processes  1; # use &amp;quot;auto&amp;quot; to use all available cores (high performance)&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections  1024; # increase if you need more connections&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    # server_names_hash_bucket_size controls the maximum length&lt;br /&gt;
    # of a virtual host entry (ie the length of the domain name).&lt;br /&gt;
    server_names_hash_bucket_size   64;&lt;br /&gt;
    server_tokens                   off; # hide who we are&lt;br /&gt;
    sendfile                        off; # can cause issues&lt;br /&gt;
&lt;br /&gt;
    # secure nginx according to https://cipherli.st/&lt;br /&gt;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;&lt;br /&gt;
    ssl_prefer_server_ciphers on;&lt;br /&gt;
    ssl_ciphers &amp;quot;EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH&amp;quot;;&lt;br /&gt;
    ssl_ecdh_curve secp384r1; # Requires nginx &amp;gt;= 1.1.0&lt;br /&gt;
    ssl_session_cache shared:SSL:10m;&lt;br /&gt;
    ssl_session_tickets off; # Requires nginx &amp;gt;= 1.5.9&lt;br /&gt;
    ssl_stapling on; # Requires nginx &amp;gt;= 1.3.7&lt;br /&gt;
    ssl_stapling_verify on; # Requires nginx =&amp;gt; 1.3.7&lt;br /&gt;
    resolver 8.8.8.8 8.8.4.4 valid=300s;&lt;br /&gt;
    resolver_timeout 5s;&lt;br /&gt;
    add_header Strict-Transport-Security &amp;quot;max-age=63072000&amp;quot;; # https://hstspreload.org&lt;br /&gt;
    add_header X-Frame-Options DENY;&lt;br /&gt;
    add_header X-Content-Type-Options nosniff;&lt;br /&gt;
&lt;br /&gt;
    ssl_dhparam dhparam.pem;&lt;br /&gt;
&lt;br /&gt;
    # nginx will find this file in the config directory set at nginx build time&lt;br /&gt;
    include mime.types;&lt;br /&gt;
&lt;br /&gt;
    #fallback in case we can&#039;t determine a type&lt;br /&gt;
    default_type application/octet-stream;&lt;br /&gt;
&lt;br /&gt;
    # buffering causes issues&lt;br /&gt;
    proxy_buffering off;&lt;br /&gt;
&lt;br /&gt;
    # include hosts&lt;br /&gt;
    include conf.d/*.conf;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Diffie–Hellman Parameters ====&lt;br /&gt;
&lt;br /&gt;
In the above configuration &amp;lt;var&amp;gt;ssl_dhparam&amp;lt;/var&amp;gt; is used, so we need to generate a global &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file. We want to use a 4096 key size, but this can take a very long time. Because of this, we are adding an extra option (&amp;lt;var&amp;gt;dsaparam&amp;lt;/var&amp;gt;) to generate our &amp;lt;code&amp;gt;dhparam&amp;lt;/code&amp;gt; file (see [https://wiki.openssl.org/index.php/Manual:Dhparam(1)#OPTIONS this] wiki section):&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096}}&lt;br /&gt;
&lt;br /&gt;
At this point, you should be able to (re)start your nginx server, but it will not use any of the security features yet.&lt;br /&gt;
&lt;br /&gt;
==== Per site configuration files (conf.d) ====&lt;br /&gt;
&lt;br /&gt;
Since Alpine v3.5, we ship &#039;&#039;&#039;NGINX&#039;&#039;&#039; with a &amp;lt;code&amp;gt;default.conf&amp;lt;/code&amp;gt; within the {{path|/etc/nginx/conf.d}} directory.&lt;br /&gt;
&lt;br /&gt;
To add support for another website, you can add files with the &#039;&#039;&#039;.conf&#039;&#039;&#039; extension to this directory:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/alpinelinux.org.conf|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Common configuration includes ====&lt;br /&gt;
&lt;br /&gt;
If you need to setup multiple proxy setups, you can include duplicated data such as shown below:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/proxy_set_header.inc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
proxy_set_header    X-Forwarded-By       $server_addr:$server_port;&lt;br /&gt;
proxy_set_header    X-Forwarded-For      $remote_addr;&lt;br /&gt;
proxy_set_header    X-Forwarded-Proto    $scheme;&lt;br /&gt;
proxy_set_header    Host                 $host;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== acme-client ===&lt;br /&gt;
&lt;br /&gt;
To allow &#039;&#039;&#039;NGINX&#039;&#039;&#039; to support https, we need to add certificates and support for ACME (Automatic Certificate Management Environment) responses.&lt;br /&gt;
&lt;br /&gt;
==== ACME responses ====&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/acme.inc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
location /.well-known/acme-challenge {&lt;br /&gt;
    alias /var/www/acme;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add this to your proxy configuration:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Automatic generation of certificates ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
{{Cat|/etc/periodic/weekly/acme-client|&amp;lt;nowiki&amp;gt;#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for host in $hosts; do&lt;br /&gt;
        acme-client -a https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf -Nnmv $host &amp;amp;&amp;amp; renew=1&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
[ &amp;quot;$renew&amp;quot; = 1 ] &amp;amp;&amp;amp; rc-service nginx reload&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Make it executable:&lt;br /&gt;
 chmod +x /etc/periodic/weekly/acme-client&lt;br /&gt;
&lt;br /&gt;
This script will run weekly to verify whether one of your certificates is outdated and renew them when needed.&lt;br /&gt;
&lt;br /&gt;
If you have several domains, you can add them to the &#039;&#039;&#039;hosts=&#039;&#039;&#039; variable with a space between each domain. This will create a separate certificate and key for each:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org example.com foo.org bar.io&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Initial generation of keys and certificates ====&lt;br /&gt;
&lt;br /&gt;
To create your initial certificates and keys, you have to run this manually the first time:&lt;br /&gt;
&lt;br /&gt;
 {{Cmd|/etc/periodic/weekly/acme-client}}&lt;br /&gt;
&lt;br /&gt;
Watch the output and see if all goes well. When it&#039;s finished, you should have files in:&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/alpinelinux.nl/fullchain.pem&lt;br /&gt;
 /etc/ssl/acme/private/alpinelinux.org/privkey.pem&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Per site HTTPS configuration ====&lt;br /&gt;
&lt;br /&gt;
Add the following below the previous HTTP configuration:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Redirect HTTP to HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Shared configuration ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
&lt;br /&gt;
{{Cat|/etc/nginx/conf.d/redirect_http.inc|&amp;lt;nowiki&amp;gt;&lt;br /&gt;
location / {&lt;br /&gt;
        return 301 https://$host$request_uri;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
==== Update host configuration ====&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
    include       conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Complete host example with IPv6 support ===&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# alpinelinux.org&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  80;&lt;br /&gt;
    listen                  [::]:80;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    include                 conf.d/acme.inc;&lt;br /&gt;
    include                 conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    listen                  [::]:443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14179</id>
		<title>Nginx as reverse proxy with acme (letsencrypt)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14179"/>
		<updated>2017-12-06T20:33:51Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* Automatic generate certificates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This setup will allow you to have multiple servers/containers be accessible via a single IP address with the added benefit of centralized generation of letsencrypt certificates and secure https (according to ssllabs ssltest). Be aware you first need to setup regular HTTP server to be able to generate your HTTPS certificates and keys. After you have generated them you can add your HTTPS host based configuration.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
For this howto we need three tools, NGINX, acme-client and openssl (for generating Diffie–Hellman Parameters).&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add nginx acme-client openssl}}&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTP ===&lt;br /&gt;
&lt;br /&gt;
==== Global configuration ====&lt;br /&gt;
&lt;br /&gt;
First step is to refactor our global nginx.conf. Its target at a low traffic http server, to increase performance make changes at top level.&lt;br /&gt;
&lt;br /&gt;
The security settings are taken from https://cipherli.st . Please also read https://hstspreload.org for details about HSTS.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ngnix configuration file&lt;br /&gt;
&lt;br /&gt;
user  nginx;&lt;br /&gt;
&lt;br /&gt;
worker_processes  1; # use &amp;quot;auto&amp;quot; to use all available cores (high performance)&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections  1024; # increase if you need more connections&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    # server_names_hash_bucket_size controls the maximum length&lt;br /&gt;
    # of a virtual host entry (ie the length of the domain name).&lt;br /&gt;
    server_names_hash_bucket_size   64;&lt;br /&gt;
    server_tokens                   off; # hide who we are&lt;br /&gt;
    sendfile                        off; # can cause issues&lt;br /&gt;
&lt;br /&gt;
    # secure nginx according to https://cipherli.st/&lt;br /&gt;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;&lt;br /&gt;
    ssl_prefer_server_ciphers on;&lt;br /&gt;
    ssl_ciphers &amp;quot;EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH&amp;quot;;&lt;br /&gt;
    ssl_ecdh_curve secp384r1; # Requires nginx &amp;gt;= 1.1.0&lt;br /&gt;
    ssl_session_cache shared:SSL:10m;&lt;br /&gt;
    ssl_session_tickets off; # Requires nginx &amp;gt;= 1.5.9&lt;br /&gt;
    ssl_stapling on; # Requires nginx &amp;gt;= 1.3.7&lt;br /&gt;
    ssl_stapling_verify on; # Requires nginx =&amp;gt; 1.3.7&lt;br /&gt;
    resolver 8.8.8.8 8.8.4.4 valid=300s;&lt;br /&gt;
    resolver_timeout 5s;&lt;br /&gt;
    add_header Strict-Transport-Security &amp;quot;max-age=63072000&amp;quot;; # https://hstspreload.org&lt;br /&gt;
    add_header X-Frame-Options DENY;&lt;br /&gt;
    add_header X-Content-Type-Options nosniff;&lt;br /&gt;
&lt;br /&gt;
    ssl_dhparam dhparam.pem;&lt;br /&gt;
&lt;br /&gt;
    # nginx will find this file in the config directory set at nginx build time&lt;br /&gt;
    include mime.types;&lt;br /&gt;
&lt;br /&gt;
    #fallback in case we can&#039;t determine a type&lt;br /&gt;
    default_type application/octet-stream;&lt;br /&gt;
&lt;br /&gt;
    # buffering causes issues&lt;br /&gt;
    proxy_buffering off;&lt;br /&gt;
&lt;br /&gt;
    # include hosts&lt;br /&gt;
    include conf.d/*.conf;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Diffie–Hellman Parameters ====&lt;br /&gt;
&lt;br /&gt;
In the above configuration ssl_dhparam is used so we need to generate a global dhparam file. We want to use a 4096 key size but this can take a very long time. Because of this we are adding an extra option (dsaparam) to generate our dhparam file (see: https://wiki.openssl.org/index.php/Manual:Dhparam(1)#OPTIONS)&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096}}&lt;br /&gt;
&lt;br /&gt;
At this point you should be able to (re)start your nginx server but it will not use any of the security features (yet).&lt;br /&gt;
&lt;br /&gt;
==== Per site configuration files (conf.d) ====&lt;br /&gt;
&lt;br /&gt;
Since Alpine v3.5 we ship NGINX with an default.conf within the /etc/nginx/conf.d directory.&lt;br /&gt;
To add support for another website you can add files with the .conf extension to this directory.&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Common configuration includes ====&lt;br /&gt;
&lt;br /&gt;
If you need to setup multiple proxy setups you can include duplicated data like shown below.&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/proxy_set_header.inc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
proxy_set_header    X-Forwarded-By       $server_addr:$server_port;&lt;br /&gt;
proxy_set_header    X-Forwarded-For      $remote_addr;&lt;br /&gt;
proxy_set_header    X-Forwarded-Proto    $scheme;&lt;br /&gt;
proxy_set_header    Host                 $host;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== acme-client ===&lt;br /&gt;
&lt;br /&gt;
To allow NGINX to support https we need to add certificates and support for ACME (Automatic Certificate Management Environment) responses.&lt;br /&gt;
&lt;br /&gt;
==== ACME responses ====&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/acme.inc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
location /.well-known/acme-challenge {&lt;br /&gt;
    alias /var/www/acme;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add this to your proxy configuration&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Automatic generate certificates ====&lt;br /&gt;
&lt;br /&gt;
Create the following file and make it executable:&lt;br /&gt;
 /etc/periodic/weekly/acme-client&lt;br /&gt;
 chmod +x /etc/periodic/weekly/acme-client&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for host in $hosts; do&lt;br /&gt;
        acme-client -a https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf -Nnmv $host &amp;amp;&amp;amp; renew=1&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
[ &amp;quot;$renew&amp;quot; = 1 ] &amp;amp;&amp;amp; rc-service nginx reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script will run weekly to verify if one of your certificates is outdated and renew them when needed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If you have several domains, you can add them to the &#039;&#039;&#039;hosts=&#039;&#039;&#039; variable with a space between each domain. This will create a separate certificate and key for each:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org example.com foo.org bar.io&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Initial generation of keys and certificates ====&lt;br /&gt;
&lt;br /&gt;
To create your initial certificates and keys you have to run this manually the first time.&lt;br /&gt;
&lt;br /&gt;
 {{Cmd|/etc/periodic/weekly/acme-client}}&lt;br /&gt;
&lt;br /&gt;
Watch the output and see if all goes well. When its finished you should have files in:&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/alpinelinux.nl/fullchain.pem&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/private/alpinelinux.org/privkey.pem&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Per site HTTPS configuration ====&lt;br /&gt;
&lt;br /&gt;
Add the following below the previous HTTP configuration:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Redirect HTTP to HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Shared configuration ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/redirect_http.inc&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
location / {&lt;br /&gt;
        return 301 https://$host$request_uri;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update host configuration ====&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
    include       conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Complete host example with IPv6 support ===&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# alpinelinux.org&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  80;&lt;br /&gt;
    listen                  [::]:80;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    include                 conf.d/acme.inc;&lt;br /&gt;
    include                 conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    listen                  [::]:443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14178</id>
		<title>Nginx as reverse proxy with acme (letsencrypt)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14178"/>
		<updated>2017-12-06T20:31:55Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* Automatic generate certificates */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This setup will allow you to have multiple servers/containers be accessible via a single IP address with the added benefit of centralized generation of letsencrypt certificates and secure https (according to ssllabs ssltest). Be aware you first need to setup regular HTTP server to be able to generate your HTTPS certificates and keys. After you have generated them you can add your HTTPS host based configuration.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
For this howto we need three tools, NGINX, acme-client and openssl (for generating Diffie–Hellman Parameters).&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add nginx acme-client openssl}}&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTP ===&lt;br /&gt;
&lt;br /&gt;
==== Global configuration ====&lt;br /&gt;
&lt;br /&gt;
First step is to refactor our global nginx.conf. Its target at a low traffic http server, to increase performance make changes at top level.&lt;br /&gt;
&lt;br /&gt;
The security settings are taken from https://cipherli.st . Please also read https://hstspreload.org for details about HSTS.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ngnix configuration file&lt;br /&gt;
&lt;br /&gt;
user  nginx;&lt;br /&gt;
&lt;br /&gt;
worker_processes  1; # use &amp;quot;auto&amp;quot; to use all available cores (high performance)&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections  1024; # increase if you need more connections&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    # server_names_hash_bucket_size controls the maximum length&lt;br /&gt;
    # of a virtual host entry (ie the length of the domain name).&lt;br /&gt;
    server_names_hash_bucket_size   64;&lt;br /&gt;
    server_tokens                   off; # hide who we are&lt;br /&gt;
    sendfile                        off; # can cause issues&lt;br /&gt;
&lt;br /&gt;
    # secure nginx according to https://cipherli.st/&lt;br /&gt;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;&lt;br /&gt;
    ssl_prefer_server_ciphers on;&lt;br /&gt;
    ssl_ciphers &amp;quot;EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH&amp;quot;;&lt;br /&gt;
    ssl_ecdh_curve secp384r1; # Requires nginx &amp;gt;= 1.1.0&lt;br /&gt;
    ssl_session_cache shared:SSL:10m;&lt;br /&gt;
    ssl_session_tickets off; # Requires nginx &amp;gt;= 1.5.9&lt;br /&gt;
    ssl_stapling on; # Requires nginx &amp;gt;= 1.3.7&lt;br /&gt;
    ssl_stapling_verify on; # Requires nginx =&amp;gt; 1.3.7&lt;br /&gt;
    resolver 8.8.8.8 8.8.4.4 valid=300s;&lt;br /&gt;
    resolver_timeout 5s;&lt;br /&gt;
    add_header Strict-Transport-Security &amp;quot;max-age=63072000&amp;quot;; # https://hstspreload.org&lt;br /&gt;
    add_header X-Frame-Options DENY;&lt;br /&gt;
    add_header X-Content-Type-Options nosniff;&lt;br /&gt;
&lt;br /&gt;
    ssl_dhparam dhparam.pem;&lt;br /&gt;
&lt;br /&gt;
    # nginx will find this file in the config directory set at nginx build time&lt;br /&gt;
    include mime.types;&lt;br /&gt;
&lt;br /&gt;
    #fallback in case we can&#039;t determine a type&lt;br /&gt;
    default_type application/octet-stream;&lt;br /&gt;
&lt;br /&gt;
    # buffering causes issues&lt;br /&gt;
    proxy_buffering off;&lt;br /&gt;
&lt;br /&gt;
    # include hosts&lt;br /&gt;
    include conf.d/*.conf;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Diffie–Hellman Parameters ====&lt;br /&gt;
&lt;br /&gt;
In the above configuration ssl_dhparam is used so we need to generate a global dhparam file. We want to use a 4096 key size but this can take a very long time. Because of this we are adding an extra option (dsaparam) to generate our dhparam file (see: https://wiki.openssl.org/index.php/Manual:Dhparam(1)#OPTIONS)&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096}}&lt;br /&gt;
&lt;br /&gt;
At this point you should be able to (re)start your nginx server but it will not use any of the security features (yet).&lt;br /&gt;
&lt;br /&gt;
==== Per site configuration files (conf.d) ====&lt;br /&gt;
&lt;br /&gt;
Since Alpine v3.5 we ship NGINX with an default.conf within the /etc/nginx/conf.d directory.&lt;br /&gt;
To add support for another website you can add files with the .conf extension to this directory.&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Common configuration includes ====&lt;br /&gt;
&lt;br /&gt;
If you need to setup multiple proxy setups you can include duplicated data like shown below.&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/proxy_set_header.inc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
proxy_set_header    X-Forwarded-By       $server_addr:$server_port;&lt;br /&gt;
proxy_set_header    X-Forwarded-For      $remote_addr;&lt;br /&gt;
proxy_set_header    X-Forwarded-Proto    $scheme;&lt;br /&gt;
proxy_set_header    Host                 $host;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== acme-client ===&lt;br /&gt;
&lt;br /&gt;
To allow NGINX to support https we need to add certificates and support for ACME (Automatic Certificate Management Environment) responses.&lt;br /&gt;
&lt;br /&gt;
==== ACME responses ====&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/acme.inc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
location /.well-known/acme-challenge {&lt;br /&gt;
    alias /var/www/acme;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add this to your proxy configuration&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Automatic generate certificates ====&lt;br /&gt;
&lt;br /&gt;
Create the following file and make it executable:&lt;br /&gt;
 /etc/periodic/weekly/acme-client&lt;br /&gt;
 chmod +x /etc/periodic/weekly/acme-client&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for host in $hosts; do&lt;br /&gt;
        acme-client -a https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf -Nnmv $host &amp;amp;&amp;amp; renew=1&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
[ &amp;quot;$renew&amp;quot; = 1 ] &amp;amp;&amp;amp; rc-service nginx reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script will run weekly to verify if one of your certificates is outdated and renew them when needed.&lt;br /&gt;
&amp;lt;br&amp;gt;&lt;br /&gt;
If you have several domains, you can add them to the &#039;&#039;&#039;hosts=&#039;&#039;&#039; line with a space between each. This will create a separate certificate and key for each:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
...&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org example.com foo.org bar.io&amp;quot;&lt;br /&gt;
...&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Initial generation of keys and certificates ====&lt;br /&gt;
&lt;br /&gt;
To create your initial certificates and keys you have to run this manually the first time.&lt;br /&gt;
&lt;br /&gt;
 {{Cmd|/etc/periodic/weekly/acme-client}}&lt;br /&gt;
&lt;br /&gt;
Watch the output and see if all goes well. When its finished you should have files in:&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/alpinelinux.nl/fullchain.pem&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/private/alpinelinux.org/privkey.pem&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Per site HTTPS configuration ====&lt;br /&gt;
&lt;br /&gt;
Add the following below the previous HTTP configuration:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Redirect HTTP to HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Shared configuration ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/redirect_http.inc&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
location / {&lt;br /&gt;
        return 301 https://$host$request_uri;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update host configuration ====&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
    include       conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Complete host example with IPv6 support ===&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# alpinelinux.org&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  80;&lt;br /&gt;
    listen                  [::]:80;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    include                 conf.d/acme.inc;&lt;br /&gt;
    include                 conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    listen                  [::]:443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=User:Flaxe&amp;diff=14174</id>
		<title>User:Flaxe</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User:Flaxe&amp;diff=14174"/>
		<updated>2017-12-04T17:57:53Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hello, I am Flaxe from Sweden :)&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=User:Flaxe&amp;diff=14173</id>
		<title>User:Flaxe</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=User:Flaxe&amp;diff=14173"/>
		<updated>2017-12-04T17:57:37Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: Created page with &amp;quot;Hello, I am Flaxe :)&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hello, I am Flaxe :)&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Hosting_services_on_Alpine&amp;diff=14172</id>
		<title>Hosting services on Alpine</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Hosting_services_on_Alpine&amp;diff=14172"/>
		<updated>2017-12-04T17:57:05Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: Fixed broken links etc&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
Alpine is well suited for hosting email-, web- or other network-related services.&amp;lt;BR&amp;gt;&lt;br /&gt;
Your biggest task is to figure out what you want your system to do.&lt;br /&gt;
&lt;br /&gt;
== Preparing Alpine ==&lt;br /&gt;
First you need to get alpine up and running.&amp;lt;BR&amp;gt;&lt;br /&gt;
Follow the [[Installation]] instructions on how to get your Alpine booted.&lt;br /&gt;
&lt;br /&gt;
If nothing else is mentioned in the below instructions, you should use the latest stable release:{{downloads|alpine}}&lt;br /&gt;
&lt;br /&gt;
=== VServer or not ===&lt;br /&gt;
VServer itself has nothing to do with the various services.&amp;lt;BR&amp;gt;&lt;br /&gt;
But if you intend to run multiple services on same box (e.g. mail and webhosting) it might be wise to run the various services in separate vserver-guests.&lt;br /&gt;
&lt;br /&gt;
* [[Setting up a basic vserver]] | &#039;&#039;Basic information on how to set up vserver hosts/guests&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mail ==&lt;br /&gt;
We split the &#039;Mail&#039; section into various tasks.&amp;lt;BR&amp;gt;&lt;br /&gt;
One task is to gather and process mail. Some other task would be to prevent spam and virus etc.&amp;lt;BR&amp;gt;&lt;br /&gt;
Finally we need to make sure the user can fetch/read his mail.&lt;br /&gt;
&lt;br /&gt;
=== Receive mail ===&lt;br /&gt;
&lt;br /&gt;
* [[Setting up postfix with virtual domains]] | &#039;&#039;Postfix can be configured in multiple ways - Here we do it with virtual domains&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Processing mail - Virus protection ===&lt;br /&gt;
&lt;br /&gt;
* [[Protecting_your_email_server_with_Alpine#Setting_up_the_Virus_scanner|Setting up ClamAV for Postfix]] | &#039;&#039;Referrers to [[Setting_up_postfix_with_virtual_domains]] instructions&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Processing mail - Spam protection ===&lt;br /&gt;
&lt;br /&gt;
* [[Protecting_your_email_server_with_Alpine#Setting_up_the_Greylisting_Server|Setting up Gross for Postfix]] | &#039;&#039;Referrers to [[Setting_up_postfix_with_virtual_domains]] instructions&#039;&#039;&lt;br /&gt;
* [[Protecting_your_email_server_with_Alpine#Setting_up_the_SMTP_filter|Setting up ClamSMTP]] | &#039;&#039;Use ClamSMTP to provide advanced content and virus filtering for spam&#039;&#039;&lt;br /&gt;
* [[Protecting_your_email_server_with_Alpine#Setting_up_SaneSecurity_.26_MSRBL_extra_definitions|Setting up SaneSecurity &amp;amp; MSRBL extra definitions]] | &#039;&#039;Another good way of catching SPAM is Sanesecurity and MSRBL definitions&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Delivering mail to the user ===&lt;br /&gt;
&lt;br /&gt;
* [[Setting up dovecot with imap and ssl]] | &#039;&#039;Secure way to fetch you mail from the mailer daemon&#039;&#039;&lt;br /&gt;
* [[Setting up dovecot with imap and tls]] | &#039;&#039;Secure way to fetch you mail from the mailer daemon&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Other Mail-related documents ===&lt;br /&gt;
&lt;br /&gt;
* [[Hosting Web/Email services on Alpine]] | &#039;&#039;Describes multiple services on same document&#039;&#039;&lt;br /&gt;
* [[Protecting your email server with Alpine]] | &#039;&#039;Describes multiple services on same document&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Web ==&lt;br /&gt;
&lt;br /&gt;
* [[Setting up trac wiki]] | &#039;&#039;A ticket/wiki system&#039;&#039;&lt;br /&gt;
* [[Lighttpd]] | &#039;&#039;Lighttpd web server&#039;&#039;&lt;br /&gt;
* [[Cherokee]] | &#039;&#039;Cherokee web server&#039;&#039;&lt;br /&gt;
* [[Apache]] | &#039;&#039;Apache web server&#039;&#039;&lt;br /&gt;
* [[Darkhttpd]] | &#039;&#039;Darkhttpd web server&#039;&#039;&lt;br /&gt;
* [[Nginx]] | &#039;&#039;Nginx web server&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== SSH ==&lt;br /&gt;
&lt;br /&gt;
* [[Setting up a ssh-server]] | &#039;&#039;OpenSSH and Dropbear SSH servers&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== DNS ==&lt;br /&gt;
&lt;br /&gt;
* [[Setting up unbound DNS server]] | &#039;&#039;A validating, recursive, and caching DNS resolver that supports DNSSEC&#039;&#039;&lt;br /&gt;
* [[Setting up nsd DNS server]] | &#039;&#039;An authoritative-only DNS server&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Proxy ==&lt;br /&gt;
&lt;br /&gt;
* [[Setting up Explicit Squid Proxy]] | &#039;&#039;Configuring an explicit Squid proxy server&#039;&#039;&lt;br /&gt;
* [[Setting up Transparent Squid Proxy]] | &#039;&#039;Configuring a transparent Squid proxy server&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Also see =&lt;br /&gt;
&lt;br /&gt;
You&#039;ll probably also want to look at [[Tutorials and Howtos]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;br /&gt;
[[Category:Mail]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Hosting_services_on_Alpine&amp;diff=14171</id>
		<title>Hosting services on Alpine</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Hosting_services_on_Alpine&amp;diff=14171"/>
		<updated>2017-12-04T17:39:31Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* Web */ Added Nginx web server&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Introduction =&lt;br /&gt;
Alpine is well suited for hosting email-, web- or other network-related services.&amp;lt;BR&amp;gt;&lt;br /&gt;
Your biggest task is to figure out what you want your system to do.&lt;br /&gt;
&lt;br /&gt;
== Preparing Alpine ==&lt;br /&gt;
First you need to get alpine up and running.&amp;lt;BR&amp;gt;&lt;br /&gt;
Follow the [[Installing_Alpine]] instructions on how to get your Alpine booted.&lt;br /&gt;
&lt;br /&gt;
If nothing else is mentioned in the below instructions, you should use the latest stable release:{{downloads|alpine}}&lt;br /&gt;
&lt;br /&gt;
=== VServer or not ===&lt;br /&gt;
VServer itself has nothing to do with the various services.&amp;lt;BR&amp;gt;&lt;br /&gt;
But if you intend to run multiple services on same box (e.g. mail and webhosting) it might be wise to run the various services in separate vserver-guests.&lt;br /&gt;
&lt;br /&gt;
* [[Setting_up_a_basic_vserver]] | &#039;&#039;Basic information on how to set up vserver hosts/guests&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Mail ==&lt;br /&gt;
We split the &#039;Mail&#039; section into various tasks.&amp;lt;BR&amp;gt;&lt;br /&gt;
One task is to gather and process mail. Some other task would be to prevent spam and virus etc.&amp;lt;BR&amp;gt;&lt;br /&gt;
Finally we need to make sure the user can fetch/read his mail.&lt;br /&gt;
&lt;br /&gt;
=== Receive mail ===&lt;br /&gt;
&lt;br /&gt;
* [[Setting_up_postfix_with_virtual_domains]] | &#039;&#039;Postfix can be configured in multiple ways - Here we do it with virtual domains&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Processing mail - Virus protection ===&lt;br /&gt;
&lt;br /&gt;
* [[Setting_up_clamav_for_postfix]] | &#039;&#039;Referrers to [[Setting_up_postfix_with_virtual_domains]] instructions&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Processing mail - Spam protection ===&lt;br /&gt;
&lt;br /&gt;
* [[Setting_up_gross_for_postfix]] | &#039;&#039;Referrers to [[Setting_up_postfix_with_virtual_domains]] instructions&#039;&#039;&lt;br /&gt;
* [[Setting_up_clamsmtp]] | &#039;&#039;Use ClamSMTP to provide advanced content and virus filtering for spam&#039;&#039;&lt;br /&gt;
* http://www.sanesecurity.co.uk/ | &#039;&#039;Another good way of catching SPAM is Sanesecurity and MSRBL definitions&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Delivering mail to the user ===&lt;br /&gt;
&lt;br /&gt;
* [[Setting_up_dovecot_with_imap_and_ssl]] | &#039;&#039;Secure way to fetch you mail from the mailer daemon&#039;&#039;&lt;br /&gt;
* [[Setting_up_dovecot_with_imap_and_tls]] | &#039;&#039;Secure way to fetch you mail from the mailer daemon&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
=== Other Mail-related documents ===&lt;br /&gt;
&lt;br /&gt;
* [[Hosting_Web/Email_services_on_Alpine]] | &#039;&#039;Describes multiple services on same document&#039;&#039;&lt;br /&gt;
* [[Protecting_your_email_server_with_Alpine]] | &#039;&#039;Describes multiple services on same document&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Web ==&lt;br /&gt;
&lt;br /&gt;
* [[Setting_up_trac_wiki]] | &#039;&#039;A ticket/wiki system&#039;&#039;&lt;br /&gt;
* [[Lighttpd]] | &#039;&#039;Lighttpd web server&#039;&#039;&lt;br /&gt;
* [[Cherokee]] | &#039;&#039;Cherokee web server&#039;&#039;&lt;br /&gt;
* [[Apache]] | &#039;&#039;Apache web server&#039;&#039;&lt;br /&gt;
* [[Darkhttpd]] | &#039;&#039;Darkhttpd web server&#039;&#039;&lt;br /&gt;
* [[Nginx]] | &#039;&#039;Nginx web server&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== SSH ==&lt;br /&gt;
&lt;br /&gt;
* [[Setting_up_a_ssh-server]] | &#039;&#039;OpenSSH and Dropbear SSH servers&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== DNS ==&lt;br /&gt;
&lt;br /&gt;
* [[Setting_up_unbound_DNS_server]] | &#039;&#039;A validating, recursive, and caching DNS resolver that supports DNSSEC&#039;&#039;&lt;br /&gt;
* [[Setting_up_nsd_DNS_server]] | &#039;&#039;An authoritative-only DNS server&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
== Proxy ==&lt;br /&gt;
&lt;br /&gt;
* [[Setting up Explicit Squid Proxy]] | &#039;&#039;Configuring an explicit Squid proxy server&#039;&#039;&lt;br /&gt;
* [[Setting up Transparent Squid Proxy]] | &#039;&#039;Configuring a transparent Squid proxy server&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
= Also see =&lt;br /&gt;
&lt;br /&gt;
You&#039;ll probably also want to look at [[Tutorials and Howtos]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;br /&gt;
[[Category:Mail]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx_with_PHP&amp;diff=14170</id>
		<title>Nginx with PHP</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx_with_PHP&amp;diff=14170"/>
		<updated>2017-12-04T17:38:23Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: Added Category:PHP&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{:Nginx}}&lt;br /&gt;
&lt;br /&gt;
=== PHP Installation ===&lt;br /&gt;
PHP packages is available in the Alpine Linux repositories. To install php5 with modules run:&lt;br /&gt;
{{cmd|apk add php5-fpm php5-mcrypt php5-soap php5-openssl php5-gmp php5-pdo_odbc php5-json php5-dom php5-pdo php5-zip php5-mysql php5-mysqli php5-sqlite3 php5-apcu php5-pdo_pgsql php5-bcmath php5-gd php5-xcache php5-odbc php5-pdo_mysql php5-pdo_sqlite php5-gettext php5-xmlreader php5-xmlrpc php5-bz2 php5-memcache php5-mssql php5-iconv php5-pdo_dblib php5-curl php5-ctype}}&lt;br /&gt;
&lt;br /&gt;
Perhaps you do not need all these PHP modules. Install modules according to your needs.&lt;br /&gt;
&lt;br /&gt;
=== Configuration ===&lt;br /&gt;
&lt;br /&gt;
Defining ENV variables which will be used in configuration.&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;PHP_FPM_USER=&amp;quot;www&amp;quot;&lt;br /&gt;
PHP_FPM_GROUP=&amp;quot;www&amp;quot;&lt;br /&gt;
PHP_FPM_LISTEN_MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
PHP_MEMORY_LIMIT=&amp;quot;512M&amp;quot;&lt;br /&gt;
PHP_MAX_UPLOAD=&amp;quot;50M&amp;quot;&lt;br /&gt;
PHP_MAX_FILE_UPLOAD=&amp;quot;200&amp;quot;&lt;br /&gt;
PHP_MAX_POST=&amp;quot;100M&amp;quot;&lt;br /&gt;
PHP_DISPLAY_ERRORS=&amp;quot;On&amp;quot;&lt;br /&gt;
PHP_DISPLAY_STARTUP_ERRORS=&amp;quot;On&amp;quot;&lt;br /&gt;
PHP_ERROR_REPORTING=&amp;quot;E_COMPILE_ERROR\|E_RECOVERABLE_ERROR\|E_ERROR\|E_CORE_ERROR&amp;quot;&lt;br /&gt;
PHP_CGI_FIX_PATHINFO=0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
Modify variables according to your needs.&lt;br /&gt;
&lt;br /&gt;
Modifying configuration file php-fpm.conf&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;sed -i &amp;quot;s|;listen.owner\s*=\s*nobody|listen.owner = ${PHP_FPM_USER}|g&amp;quot; /etc/php5/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|;listen.group\s*=\s*nobody|listen.group = ${PHP_FPM_GROUP}|g&amp;quot; /etc/php5/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|;listen.mode\s*=\s*0660|listen.mode = ${PHP_FPM_LISTEN_MODE}|g&amp;quot; /etc/php5/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|user\s*=\s*nobody|user = ${PHP_FPM_USER}|g&amp;quot; /etc/php5/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|group\s*=\s*nobody|group = ${PHP_FPM_GROUP}|g&amp;quot; /etc/php5/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|;log_level\s*=\s*notice|log_level = notice|g&amp;quot; /etc/php5/php-fpm.conf #uncommenting line &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Modifying configuration file php.ini&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;sed -i &amp;quot;s|display_errors\s*=\s*Off|display_errors = ${PHP_DISPLAY_ERRORS}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|display_startup_errors\s*=\s*Off|display_startup_errors = ${PHP_DISPLAY_STARTUP_ERRORS}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|error_reporting\s*=\s*E_ALL &amp;amp; ~E_DEPRECATED &amp;amp; ~E_STRICT|error_reporting = ${PHP_ERROR_REPORTING}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*memory_limit =.*|memory_limit = ${PHP_MEMORY_LIMIT}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*upload_max_filesize =.*|upload_max_filesize = ${PHP_MAX_UPLOAD}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*max_file_uploads =.*|max_file_uploads = ${PHP_MAX_FILE_UPLOAD}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*post_max_size =.*|post_max_size = ${PHP_MAX_POST}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*cgi.fix_pathinfo=.*|cgi.fix_pathinfo= ${PHP_CGI_FIX_PATHINFO}|i&amp;quot; /etc/php5/php.ini&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
To add PHP support to Nginx we should modify Nginx configuration file:&lt;br /&gt;
{{cmd|vi /etc/nginx/nginx.conf}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
user                            www;&lt;br /&gt;
worker_processes                1;&lt;br /&gt;
&lt;br /&gt;
error_log                       /var/log/nginx/error.log warn;&lt;br /&gt;
pid                             /var/run/nginx.pid;&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections          1024;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    include                     /etc/nginx/mime.types;&lt;br /&gt;
    default_type                application/octet-stream;&lt;br /&gt;
    sendfile                    on;&lt;br /&gt;
    access_log                  /var/log/nginx/access.log;&lt;br /&gt;
    keepalive_timeout           3000;&lt;br /&gt;
    server {&lt;br /&gt;
        listen                  80;&lt;br /&gt;
        root                    /www;&lt;br /&gt;
        index                   index.html index.htm index.php;&lt;br /&gt;
        server_name             localhost;&lt;br /&gt;
        client_max_body_size    32m;&lt;br /&gt;
        error_page              500 502 503 504  /50x.html;&lt;br /&gt;
        location = /50x.html {&lt;br /&gt;
              root              /var/lib/nginx/html;&lt;br /&gt;
        }&lt;br /&gt;
        location ~ \.php$ {&lt;br /&gt;
              fastcgi_pass      127.0.0.1:9000;&lt;br /&gt;
              fastcgi_index     index.php;&lt;br /&gt;
              include           fastcgi.conf;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In our configuration we have line: &amp;quot;fastcgi_pass   127.0.0.1:9000&amp;quot; &amp;lt;br /&amp;gt;&lt;br /&gt;
It should be corresponing to the line &amp;quot;listen = 127.0.0.1:9000&amp;quot; in PHP configuration file /etc/php5/php-fpm.conf&lt;br /&gt;
&lt;br /&gt;
=== Timezone ===&lt;br /&gt;
For configuring Timezone you may use tzdata package which can be installed by running:&lt;br /&gt;
{{cmd|apk add tzdata}}&lt;br /&gt;
&lt;br /&gt;
Timezone configuration&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;TIMEZONE=&amp;quot;Europe/Helsinki&amp;quot;&lt;br /&gt;
cp /usr/share/zoneinfo/${TIMEZONE} /etc/localtime&lt;br /&gt;
echo &amp;quot;${TIMEZONE}&amp;quot; &amp;gt; /etc/timezone&lt;br /&gt;
sed -i &amp;quot;s|;*date.timezone =.*|date.timezone = ${TIMEZONE}|i&amp;quot; /etc/php5/php.ini&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Sample PHP page ===&lt;br /&gt;
{{cmd|vi /www/phpinfo.php}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	phpinfo();&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting Nginx with PHP ===&lt;br /&gt;
Nginx should be restarted because we have changed it&#039;s configuration. Restart it by running:&lt;br /&gt;
{{cmd|rc-service nginx restart}}&lt;br /&gt;
&lt;br /&gt;
After the installation PHP is not running. Start it by running:&lt;br /&gt;
{{cmd|rc-service php-fpm start}}&lt;br /&gt;
&lt;br /&gt;
=== Runlevel ===&lt;br /&gt;
Normally you want to start the web server when the system is launching. This is done by adding Nginx and PHP to the needed runlevel.&lt;br /&gt;
{{cmd|rc-update add nginx default&lt;br /&gt;
rc-update add php-fpm default}}&lt;br /&gt;
&lt;br /&gt;
Now they should start automatically when you boot your machine next time. To test that run:&lt;br /&gt;
{{cmd|reboot}}&lt;br /&gt;
&lt;br /&gt;
To make sure that Nginx and PHP are started run command:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;ps aux | grep &#039;nginx\|php-fpm&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You should get something like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  263 root       0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf&lt;br /&gt;
  264 www        0:00 nginx: worker process&lt;br /&gt;
  291 root       0:00 php-fpm: master process (/etc/php5/php-fpm.conf)&lt;br /&gt;
  302 www        0:00 php-fpm: pool www&lt;br /&gt;
  303 www        0:00 php-fpm: pool www&lt;br /&gt;
  310 root       0:00 grep nginx\|php-fpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing Nginx with PHP ===&lt;br /&gt;
This section is assuming that nginx is running and sample html page &amp;quot;/www/phpinfo.php&amp;quot; is created. Launch a web browser and point it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://X.X.X.X/phpinfo.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where X.X.X.X is IP address of your web server&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
If everything was set up correctly, you should see information about your web server.&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If PHP is not started check php-fpm log file&lt;br /&gt;
{{cmd|less /var/log/php-fpm.log}}&lt;br /&gt;
&lt;br /&gt;
Make sure that configuration files do not contain errors&lt;br /&gt;
{{cmd|vi /etc/php5/php-fpm.conf&lt;br /&gt;
vi /etc/php5/php.ini}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Web Server]]&lt;br /&gt;
[[Category:PHP]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx&amp;diff=14169</id>
		<title>Nginx</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx&amp;diff=14169"/>
		<updated>2017-12-04T17:37:07Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* Nginx with PHP */ Added link to setup with Acme (letsencrypt) and Category:Web Server&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[https://nginx.org/en/ Nginx] (engine x) is an HTTP and reverse proxy server, a mail proxy server, and a generic TCP/UDP proxy server&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
Nginx package is available in the Alpine Linux repositories. To install it run:&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add nginx}}&lt;br /&gt;
&lt;br /&gt;
Creating new user and group &#039;www&#039; for nginx&lt;br /&gt;
{{Cmd|adduser -D -u 1000 -g &#039;www&#039; www}}&lt;br /&gt;
&lt;br /&gt;
Create a directory for html files&lt;br /&gt;
{{Cmd|mkdir /www&lt;br /&gt;
chown -R www:www /var/lib/nginx&lt;br /&gt;
chown -R www:www /www&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
== Configuration ==&lt;br /&gt;
You may want to make backup of original nginx.conf file before writting your own&lt;br /&gt;
{{Cmd|mv /etc/nginx/nginx.conf /etc/nginx/nginx.conf.orig}}&lt;br /&gt;
&lt;br /&gt;
Configuring Nginx to listen to port 80 and process .html or .htm files&lt;br /&gt;
{{Cmd|vi /etc/nginx/nginx.conf}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
user                            www;&lt;br /&gt;
worker_processes                1;&lt;br /&gt;
&lt;br /&gt;
error_log                       /var/log/nginx/error.log warn;&lt;br /&gt;
pid                             /var/run/nginx.pid;&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections          1024;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    include                     /etc/nginx/mime.types;&lt;br /&gt;
    default_type                application/octet-stream;&lt;br /&gt;
    sendfile                    on;&lt;br /&gt;
    access_log                  /var/log/nginx/access.log;&lt;br /&gt;
    keepalive_timeout           3000;&lt;br /&gt;
    server {&lt;br /&gt;
        listen                  80;&lt;br /&gt;
        root                    /www;&lt;br /&gt;
        index                   index.html index.htm;&lt;br /&gt;
        server_name             localhost;&lt;br /&gt;
        client_max_body_size    32m;&lt;br /&gt;
        error_page              500 502 503 504  /50x.html;&lt;br /&gt;
        location = /50x.html {&lt;br /&gt;
              root              /var/lib/nginx/html;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Sample page ==&lt;br /&gt;
{{Cmd|vi /www/index.html}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;!DOCTYPE html&amp;gt;&lt;br /&gt;
&amp;lt;html lang=&amp;quot;en&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;head&amp;gt;&lt;br /&gt;
    &amp;lt;meta charset=&amp;quot;utf-8&amp;quot; /&amp;gt;&lt;br /&gt;
    &amp;lt;title&amp;gt;HTML5&amp;lt;/title&amp;gt;&lt;br /&gt;
&amp;lt;/head&amp;gt;&lt;br /&gt;
&amp;lt;body&amp;gt;&lt;br /&gt;
    Server is online&lt;br /&gt;
&amp;lt;/body&amp;gt;&lt;br /&gt;
&amp;lt;/html&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Controlling nginx ==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Start Nginx ===&lt;br /&gt;
After the installation Nginx is not running. To start Nginx, use &#039;&#039;start&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx start}}&lt;br /&gt;
&lt;br /&gt;
You will get a feedback about the status.&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
 * /run/nginx: creating directory&lt;br /&gt;
 * /run/nginx: correcting owner                         [ ok ]&lt;br /&gt;
 * Starting nginx ...                                   [ ok ]&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Restart Nginx ===&lt;br /&gt;
After changing the configuration file nginx needs to be restarted.&lt;br /&gt;
If you want to restart the web server use &#039;&#039;restart&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx restart}}&lt;br /&gt;
&lt;br /&gt;
=== Stop Nginx ===&lt;br /&gt;
If you want to stop the web server use &#039;&#039;stop&#039;&#039;.&lt;br /&gt;
{{Cmd|rc-service nginx stop}}&lt;br /&gt;
&lt;br /&gt;
=== Runlevel ===&lt;br /&gt;
Normally you want to start the web server when the system is launching. This is done by adding Nginx to the needed runlevel.&lt;br /&gt;
{{Cmd|rc-update add nginx default}}&lt;br /&gt;
&lt;br /&gt;
Now Nginx should start automatically when you boot your machine next time. To test that run:&lt;br /&gt;
{{cmd|reboot}}&lt;br /&gt;
&lt;br /&gt;
To make sure that Nginx is started run:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;ps aux | grep nginx&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You should get something like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  263 root       0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf&lt;br /&gt;
  264 www        0:00 nginx: worker process&lt;br /&gt;
  310 root       0:00 grep nginx&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Testing Nginx ==&lt;br /&gt;
This section is assuming that nginx is running and sample html page &amp;quot;/www/index.html&amp;quot; is created. Launch a web browser and point it to your web server.&lt;br /&gt;
You should get:&lt;br /&gt;
&amp;lt;pre&amp;gt;Server is online&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Troubleshooting ==&lt;br /&gt;
If Nginx is not started check Nginx log file&lt;br /&gt;
{{cmd|less /var/log/nginx/error.log}}&lt;br /&gt;
&lt;br /&gt;
Make sure that configuration file does not contain errors&lt;br /&gt;
{{cmd|vi /etc/nginx/nginx.conf}}&lt;br /&gt;
&lt;br /&gt;
== Nginx with PHP ==&lt;br /&gt;
&lt;br /&gt;
[[Nginx_with_PHP#Nginx_with_PHP|Setting Up Nginx with PHP]] &amp;lt;br&amp;gt;&lt;br /&gt;
[[Nginx_as_reverse_proxy_with_acme_(letsencrypt)|Setting Up Nginx as Reverse Proxy with acme (Let&#039;s Encrypt)]]&lt;br /&gt;
&lt;br /&gt;
[[Category:Server]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx_with_PHP&amp;diff=14168</id>
		<title>Nginx with PHP</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx_with_PHP&amp;diff=14168"/>
		<updated>2017-12-04T17:34:52Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: Added Category:Web Server&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{:Nginx}}&lt;br /&gt;
&lt;br /&gt;
=== PHP Installation ===&lt;br /&gt;
PHP packages is available in the Alpine Linux repositories. To install php5 with modules run:&lt;br /&gt;
{{cmd|apk add php5-fpm php5-mcrypt php5-soap php5-openssl php5-gmp php5-pdo_odbc php5-json php5-dom php5-pdo php5-zip php5-mysql php5-mysqli php5-sqlite3 php5-apcu php5-pdo_pgsql php5-bcmath php5-gd php5-xcache php5-odbc php5-pdo_mysql php5-pdo_sqlite php5-gettext php5-xmlreader php5-xmlrpc php5-bz2 php5-memcache php5-mssql php5-iconv php5-pdo_dblib php5-curl php5-ctype}}&lt;br /&gt;
&lt;br /&gt;
Perhaps you do not need all these PHP modules. Install modules according to your needs.&lt;br /&gt;
&lt;br /&gt;
=== Configuration ===&lt;br /&gt;
&lt;br /&gt;
Defining ENV variables which will be used in configuration.&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;PHP_FPM_USER=&amp;quot;www&amp;quot;&lt;br /&gt;
PHP_FPM_GROUP=&amp;quot;www&amp;quot;&lt;br /&gt;
PHP_FPM_LISTEN_MODE=&amp;quot;0660&amp;quot;&lt;br /&gt;
PHP_MEMORY_LIMIT=&amp;quot;512M&amp;quot;&lt;br /&gt;
PHP_MAX_UPLOAD=&amp;quot;50M&amp;quot;&lt;br /&gt;
PHP_MAX_FILE_UPLOAD=&amp;quot;200&amp;quot;&lt;br /&gt;
PHP_MAX_POST=&amp;quot;100M&amp;quot;&lt;br /&gt;
PHP_DISPLAY_ERRORS=&amp;quot;On&amp;quot;&lt;br /&gt;
PHP_DISPLAY_STARTUP_ERRORS=&amp;quot;On&amp;quot;&lt;br /&gt;
PHP_ERROR_REPORTING=&amp;quot;E_COMPILE_ERROR\|E_RECOVERABLE_ERROR\|E_ERROR\|E_CORE_ERROR&amp;quot;&lt;br /&gt;
PHP_CGI_FIX_PATHINFO=0&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
Modify variables according to your needs.&lt;br /&gt;
&lt;br /&gt;
Modifying configuration file php-fpm.conf&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;sed -i &amp;quot;s|;listen.owner\s*=\s*nobody|listen.owner = ${PHP_FPM_USER}|g&amp;quot; /etc/php5/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|;listen.group\s*=\s*nobody|listen.group = ${PHP_FPM_GROUP}|g&amp;quot; /etc/php5/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|;listen.mode\s*=\s*0660|listen.mode = ${PHP_FPM_LISTEN_MODE}|g&amp;quot; /etc/php5/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|user\s*=\s*nobody|user = ${PHP_FPM_USER}|g&amp;quot; /etc/php5/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|group\s*=\s*nobody|group = ${PHP_FPM_GROUP}|g&amp;quot; /etc/php5/php-fpm.conf&lt;br /&gt;
sed -i &amp;quot;s|;log_level\s*=\s*notice|log_level = notice|g&amp;quot; /etc/php5/php-fpm.conf #uncommenting line &amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
Modifying configuration file php.ini&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;sed -i &amp;quot;s|display_errors\s*=\s*Off|display_errors = ${PHP_DISPLAY_ERRORS}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|display_startup_errors\s*=\s*Off|display_startup_errors = ${PHP_DISPLAY_STARTUP_ERRORS}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|error_reporting\s*=\s*E_ALL &amp;amp; ~E_DEPRECATED &amp;amp; ~E_STRICT|error_reporting = ${PHP_ERROR_REPORTING}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*memory_limit =.*|memory_limit = ${PHP_MEMORY_LIMIT}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*upload_max_filesize =.*|upload_max_filesize = ${PHP_MAX_UPLOAD}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*max_file_uploads =.*|max_file_uploads = ${PHP_MAX_FILE_UPLOAD}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*post_max_size =.*|post_max_size = ${PHP_MAX_POST}|i&amp;quot; /etc/php5/php.ini&lt;br /&gt;
sed -i &amp;quot;s|;*cgi.fix_pathinfo=.*|cgi.fix_pathinfo= ${PHP_CGI_FIX_PATHINFO}|i&amp;quot; /etc/php5/php.ini&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
To add PHP support to Nginx we should modify Nginx configuration file:&lt;br /&gt;
{{cmd|vi /etc/nginx/nginx.conf}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
user                            www;&lt;br /&gt;
worker_processes                1;&lt;br /&gt;
&lt;br /&gt;
error_log                       /var/log/nginx/error.log warn;&lt;br /&gt;
pid                             /var/run/nginx.pid;&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections          1024;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    include                     /etc/nginx/mime.types;&lt;br /&gt;
    default_type                application/octet-stream;&lt;br /&gt;
    sendfile                    on;&lt;br /&gt;
    access_log                  /var/log/nginx/access.log;&lt;br /&gt;
    keepalive_timeout           3000;&lt;br /&gt;
    server {&lt;br /&gt;
        listen                  80;&lt;br /&gt;
        root                    /www;&lt;br /&gt;
        index                   index.html index.htm index.php;&lt;br /&gt;
        server_name             localhost;&lt;br /&gt;
        client_max_body_size    32m;&lt;br /&gt;
        error_page              500 502 503 504  /50x.html;&lt;br /&gt;
        location = /50x.html {&lt;br /&gt;
              root              /var/lib/nginx/html;&lt;br /&gt;
        }&lt;br /&gt;
        location ~ \.php$ {&lt;br /&gt;
              fastcgi_pass      127.0.0.1:9000;&lt;br /&gt;
              fastcgi_index     index.php;&lt;br /&gt;
              include           fastcgi.conf;&lt;br /&gt;
        }&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
In our configuration we have line: &amp;quot;fastcgi_pass   127.0.0.1:9000&amp;quot; &amp;lt;br /&amp;gt;&lt;br /&gt;
It should be corresponing to the line &amp;quot;listen = 127.0.0.1:9000&amp;quot; in PHP configuration file /etc/php5/php-fpm.conf&lt;br /&gt;
&lt;br /&gt;
=== Timezone ===&lt;br /&gt;
For configuring Timezone you may use tzdata package which can be installed by running:&lt;br /&gt;
{{cmd|apk add tzdata}}&lt;br /&gt;
&lt;br /&gt;
Timezone configuration&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;TIMEZONE=&amp;quot;Europe/Helsinki&amp;quot;&lt;br /&gt;
cp /usr/share/zoneinfo/${TIMEZONE} /etc/localtime&lt;br /&gt;
echo &amp;quot;${TIMEZONE}&amp;quot; &amp;gt; /etc/timezone&lt;br /&gt;
sed -i &amp;quot;s|;*date.timezone =.*|date.timezone = ${TIMEZONE}|i&amp;quot; /etc/php5/php.ini&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
=== Sample PHP page ===&lt;br /&gt;
{{cmd|vi /www/phpinfo.php}}&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&amp;lt;?php&lt;br /&gt;
	phpinfo();&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Starting Nginx with PHP ===&lt;br /&gt;
Nginx should be restarted because we have changed it&#039;s configuration. Restart it by running:&lt;br /&gt;
{{cmd|rc-service nginx restart}}&lt;br /&gt;
&lt;br /&gt;
After the installation PHP is not running. Start it by running:&lt;br /&gt;
{{cmd|rc-service php-fpm start}}&lt;br /&gt;
&lt;br /&gt;
=== Runlevel ===&lt;br /&gt;
Normally you want to start the web server when the system is launching. This is done by adding Nginx and PHP to the needed runlevel.&lt;br /&gt;
{{cmd|rc-update add nginx default&lt;br /&gt;
rc-update add php-fpm default}}&lt;br /&gt;
&lt;br /&gt;
Now they should start automatically when you boot your machine next time. To test that run:&lt;br /&gt;
{{cmd|reboot}}&lt;br /&gt;
&lt;br /&gt;
To make sure that Nginx and PHP are started run command:&lt;br /&gt;
{{cmd|&amp;lt;nowiki&amp;gt;ps aux | grep &#039;nginx\|php-fpm&#039;&amp;lt;/nowiki&amp;gt;}}&lt;br /&gt;
&lt;br /&gt;
You should get something like this:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
  263 root       0:00 nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf&lt;br /&gt;
  264 www        0:00 nginx: worker process&lt;br /&gt;
  291 root       0:00 php-fpm: master process (/etc/php5/php-fpm.conf)&lt;br /&gt;
  302 www        0:00 php-fpm: pool www&lt;br /&gt;
  303 www        0:00 php-fpm: pool www&lt;br /&gt;
  310 root       0:00 grep nginx\|php-fpm&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Testing Nginx with PHP ===&lt;br /&gt;
This section is assuming that nginx is running and sample html page &amp;quot;/www/phpinfo.php&amp;quot; is created. Launch a web browser and point it to &lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
http://X.X.X.X/phpinfo.php&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
where X.X.X.X is IP address of your web server&amp;lt;br /&amp;gt;&lt;br /&gt;
&amp;lt;br /&amp;gt;&lt;br /&gt;
If everything was set up correctly, you should see information about your web server.&lt;br /&gt;
&lt;br /&gt;
=== Troubleshooting ===&lt;br /&gt;
&lt;br /&gt;
If PHP is not started check php-fpm log file&lt;br /&gt;
{{cmd|less /var/log/php-fpm.log}}&lt;br /&gt;
&lt;br /&gt;
Make sure that configuration files do not contain errors&lt;br /&gt;
{{cmd|vi /etc/php5/php-fpm.conf&lt;br /&gt;
vi /etc/php5/php.ini}}&lt;br /&gt;
&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14167</id>
		<title>Nginx as reverse proxy with acme (letsencrypt)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14167"/>
		<updated>2017-12-04T17:33:38Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This setup will allow you to have multiple servers/containers be accessible via a single IP address with the added benefit of centralized generation of letsencrypt certificates and secure https (according to ssllabs ssltest). Be aware you first need to setup regular HTTP server to be able to generate your HTTPS certificates and keys. After you have generated them you can add your HTTPS host based configuration.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
For this howto we need three tools, NGINX, acme-client and openssl (for generating Diffie–Hellman Parameters).&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add nginx acme-client openssl}}&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTP ===&lt;br /&gt;
&lt;br /&gt;
==== Global configuration ====&lt;br /&gt;
&lt;br /&gt;
First step is to refactor our global nginx.conf. Its target at a low traffic http server, to increase performance make changes at top level.&lt;br /&gt;
&lt;br /&gt;
The security settings are taken from https://cipherli.st . Please also read https://hstspreload.org for details about HSTS.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ngnix configuration file&lt;br /&gt;
&lt;br /&gt;
user  nginx;&lt;br /&gt;
&lt;br /&gt;
worker_processes  1; # use &amp;quot;auto&amp;quot; to use all available cores (high performance)&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections  1024; # increase if you need more connections&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    # server_names_hash_bucket_size controls the maximum length&lt;br /&gt;
    # of a virtual host entry (ie the length of the domain name).&lt;br /&gt;
    server_names_hash_bucket_size   64;&lt;br /&gt;
    server_tokens                   off; # hide who we are&lt;br /&gt;
    sendfile                        off; # can cause issues&lt;br /&gt;
&lt;br /&gt;
    # secure nginx according to https://cipherli.st/&lt;br /&gt;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;&lt;br /&gt;
    ssl_prefer_server_ciphers on;&lt;br /&gt;
    ssl_ciphers &amp;quot;EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH&amp;quot;;&lt;br /&gt;
    ssl_ecdh_curve secp384r1; # Requires nginx &amp;gt;= 1.1.0&lt;br /&gt;
    ssl_session_cache shared:SSL:10m;&lt;br /&gt;
    ssl_session_tickets off; # Requires nginx &amp;gt;= 1.5.9&lt;br /&gt;
    ssl_stapling on; # Requires nginx &amp;gt;= 1.3.7&lt;br /&gt;
    ssl_stapling_verify on; # Requires nginx =&amp;gt; 1.3.7&lt;br /&gt;
    resolver 8.8.8.8 8.8.4.4 valid=300s;&lt;br /&gt;
    resolver_timeout 5s;&lt;br /&gt;
    add_header Strict-Transport-Security &amp;quot;max-age=63072000&amp;quot;; # https://hstspreload.org&lt;br /&gt;
    add_header X-Frame-Options DENY;&lt;br /&gt;
    add_header X-Content-Type-Options nosniff;&lt;br /&gt;
&lt;br /&gt;
    ssl_dhparam dhparam.pem;&lt;br /&gt;
&lt;br /&gt;
    # nginx will find this file in the config directory set at nginx build time&lt;br /&gt;
    include mime.types;&lt;br /&gt;
&lt;br /&gt;
    #fallback in case we can&#039;t determine a type&lt;br /&gt;
    default_type application/octet-stream;&lt;br /&gt;
&lt;br /&gt;
    # buffering causes issues&lt;br /&gt;
    proxy_buffering off;&lt;br /&gt;
&lt;br /&gt;
    # include hosts&lt;br /&gt;
    include conf.d/*.conf;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Diffie–Hellman Parameters ====&lt;br /&gt;
&lt;br /&gt;
In the above configuration ssl_dhparam is used so we need to generate a global dhparam file. We want to use a 4096 key size but this can take a very long time. Because of this we are adding an extra option (dsaparam) to generate our dhparam file (see: https://wiki.openssl.org/index.php/Manual:Dhparam(1)#OPTIONS)&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096}}&lt;br /&gt;
&lt;br /&gt;
At this point you should be able to (re)start your nginx server but it will not use any of the security features (yet).&lt;br /&gt;
&lt;br /&gt;
==== Per site configuration files (conf.d) ====&lt;br /&gt;
&lt;br /&gt;
Since Alpine v3.5 we ship NGINX with an default.conf within the /etc/nginx/conf.d directory.&lt;br /&gt;
To add support for another website you can add files with the .conf extension to this directory.&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Common configuration includes ====&lt;br /&gt;
&lt;br /&gt;
If you need to setup multiple proxy setups you can include duplicated data like shown below.&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/proxy_set_header.inc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
proxy_set_header    X-Forwarded-By       $server_addr:$server_port;&lt;br /&gt;
proxy_set_header    X-Forwarded-For      $remote_addr;&lt;br /&gt;
proxy_set_header    X-Forwarded-Proto    $scheme;&lt;br /&gt;
proxy_set_header    Host                 $host;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== acme-client ===&lt;br /&gt;
&lt;br /&gt;
To allow NGINX to support https we need to add certificates and support for ACME (Automatic Certificate Management Environment) responses.&lt;br /&gt;
&lt;br /&gt;
==== ACME responses ====&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/acme.inc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
location /.well-known/acme-challenge {&lt;br /&gt;
    alias /var/www/acme;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add this to your proxy configuration&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Automatic generate certificates ====&lt;br /&gt;
&lt;br /&gt;
Create the following file and make it executable&lt;br /&gt;
 /etc/periodic/weekly/acme-client&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for host in $hosts; do&lt;br /&gt;
        acme-client -a https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf -Nnmv $host &amp;amp;&amp;amp; renew=1&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
[ &amp;quot;$renew&amp;quot; = 1 ] &amp;amp;&amp;amp; rc-service nginx reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script will run weekly to verify if one of your certificates is outdated and renew them when needed.&lt;br /&gt;
&lt;br /&gt;
==== Initial generation of keys and certificates ====&lt;br /&gt;
&lt;br /&gt;
To create your initial certificates and keys you have to run this manually the first time.&lt;br /&gt;
&lt;br /&gt;
 {{Cmd|/etc/periodic/weekly/acme-client}}&lt;br /&gt;
&lt;br /&gt;
Watch the output and see if all goes well. When its finished you should have files in:&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/alpinelinux.nl/fullchain.pem&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/private/alpinelinux.org/privkey.pem&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Per site HTTPS configuration ====&lt;br /&gt;
&lt;br /&gt;
Add the following below the previous HTTP configuration:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Redirect HTTP to HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Shared configuration ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/redirect_http.inc&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
location / {&lt;br /&gt;
        return 301 https://$host$request_uri;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update host configuration ====&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
    include       conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Complete host example with IPv6 support ===&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# alpinelinux.org&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  80;&lt;br /&gt;
    listen                  [::]:80;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    include                 conf.d/acme.inc;&lt;br /&gt;
    include                 conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    listen                  [::]:443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
[[Category:Networking]]&lt;br /&gt;
[[Category:Web Server]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_security&amp;diff=14163</id>
		<title>Alpine security</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_security&amp;diff=14163"/>
		<updated>2017-12-02T19:29:35Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* Network statistics */ Update nethogs URL&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Note|This is work in progress. Not all packages are available at the moment.}}&lt;br /&gt;
&lt;br /&gt;
== Basics ==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
! URL&lt;br /&gt;
|-&lt;br /&gt;
| alpine-base&lt;br /&gt;
| Alpine base package&lt;br /&gt;
| http://alpinelinux.org&lt;br /&gt;
|-&lt;br /&gt;
| alpine-mirrors&lt;br /&gt;
| List of Alpine Linux Mirrors&lt;br /&gt;
| http://alpinelinux.org/&lt;br /&gt;
|-&lt;br /&gt;
| bkeymaps&lt;br /&gt;
| Binary keymaps for busybox&lt;br /&gt;
| http://dev.alpinelinux.org/alpine/bkeymaps&lt;br /&gt;
|-&lt;br /&gt;
| network-extras&lt;br /&gt;
| Meta package to pull in vlan, bonding, bridge and wifi support&lt;br /&gt;
| http://alpinelinux.org&lt;br /&gt;
|-&lt;br /&gt;
| openssl&lt;br /&gt;
| Toolkit for SSL v2/v3 and TLS v1&lt;br /&gt;
| http://openssl.org&lt;br /&gt;
|-&lt;br /&gt;
| tzdata&lt;br /&gt;
| Timezone data&lt;br /&gt;
| http://www.twinsun.com/tz/tz-link.htm&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Code Analysis ==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
! URL&lt;br /&gt;
|-&lt;br /&gt;
| rpmlint&lt;br /&gt;
| A tool for checking common errors in RPM packages&lt;br /&gt;
| http://rpmlint.zarb.org&lt;br /&gt;
|-&lt;br /&gt;
| pylint&lt;br /&gt;
| Analyzes Python code looking for bugs and signs of poor quality&lt;br /&gt;
| http://pypi.python.org/pypi/pylint&lt;br /&gt;
|-&lt;br /&gt;
| flawfinder&lt;br /&gt;
| Examines C/C++ source code for security flaws&lt;br /&gt;
| http://www.dwheeler.com/flawfinder/&lt;br /&gt;
|-&lt;br /&gt;
| rats&lt;br /&gt;
| A tool to find security related programming errors&lt;br /&gt;
| https://www.fortify.com/ssa-elements/threat-intelligence/rats.html&lt;br /&gt;
|-&lt;br /&gt;
| pychecker&lt;br /&gt;
| A analyser for python source code&lt;br /&gt;
| http://pychecker.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| pyflakes&lt;br /&gt;
| A passive checker of Python programs&lt;br /&gt;
| https://launchpad.net/pyflakes&lt;br /&gt;
|-&lt;br /&gt;
| strace&lt;br /&gt;
| A useful diagnositic, instructional, and debugging tool&lt;br /&gt;
| http://sourceforge.net/projects/strace/&lt;br /&gt;
|-&lt;br /&gt;
| netsink&lt;br /&gt;
| A Network Sinkhole for Isolated Malware Analysis&lt;br /&gt;
| https://github.com/shendo/netsink&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Todo&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| splint&lt;br /&gt;
| An implementation of the lint program &lt;br /&gt;
| http://www.splint.org/&lt;br /&gt;
|-&lt;br /&gt;
| valgrind&lt;br /&gt;
| A tool for finding memory-management problems&lt;br /&gt;
| http://valgrind.org/&lt;br /&gt;
|-&lt;br /&gt;
| pscan&lt;br /&gt;
| Limited problem scanner for C source files&lt;br /&gt;
|&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Forensics / Data recovery tools ==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
! URL&lt;br /&gt;
|-&lt;br /&gt;
| dc3dd&lt;br /&gt;
| Patched version of GNU dd for use in computer forensics &lt;br /&gt;
| http://dc3dd.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| ddrescue&lt;br /&gt;
| Data recovery tool for block devices with errors &lt;br /&gt;
| http://www.gnu.org/s/ddrescue/ddrescue.html&lt;br /&gt;
|-&lt;br /&gt;
| testdisk&lt;br /&gt;
| A powerful free data recovery software&lt;br /&gt;
| http://www.cgsecurity.org/wiki/TestDisk&lt;br /&gt;
|-&lt;br /&gt;
| scrub&lt;br /&gt;
| Disk scrubbing program&lt;br /&gt;
| http://code.google.com/p/diskscrub/&lt;br /&gt;
|-&lt;br /&gt;
| ncdu&lt;br /&gt;
| A curses-based version of the well-known &amp;quot;du&amp;quot;&lt;br /&gt;
| http://dev.yorhel.nl/ncdu&lt;br /&gt;
|-&lt;br /&gt;
| htop&lt;br /&gt;
| An interactive process viewer for Linux&lt;br /&gt;
| http://htop.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| mac-robber&lt;br /&gt;
| A tool that collects data from allocated files in a mounted file system&lt;br /&gt;
| http://www.sleuthkit.org/mac-robber/desc.php&lt;br /&gt;
|-&lt;br /&gt;
| wipe&lt;br /&gt;
| Tool for securely erasing files from magnetic media&lt;br /&gt;
| http://lambda-diode.com/software/wipe/&lt;br /&gt;
|-&lt;br /&gt;
| nwipe&lt;br /&gt;
| Securely erase disks using a variety of recognized methods&lt;br /&gt;
| http://nwipe.sourceforge.net&lt;br /&gt;
|-&lt;br /&gt;
| jhead&lt;br /&gt;
| An Exif jpeg header manipulation tool&lt;br /&gt;
| http://www.sentex.net/~mwandel/jhead/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ToDo&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| aimage&lt;br /&gt;
| Advanced Disk Imager&lt;br /&gt;
| http://www.afflib.org&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| fiwalk&lt;br /&gt;
| Batch analysis of a disk image&lt;br /&gt;
| http://www.afflib.org&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| ftimes&lt;br /&gt;
| A system baselining and evidence collection too&lt;br /&gt;
| http://ftimes.sourceforge.net/FTimes/&lt;br /&gt;
&lt;br /&gt;
http://sourceforge.net/projects/cdpr/&lt;br /&gt;
| rarcrack&lt;br /&gt;
| http://rarcrack.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
| extcarve&lt;br /&gt;
| safecopy &lt;br /&gt;
| A data recovery tool&lt;br /&gt;
| http://safecopy.sourceforge.net/&lt;br /&gt;
* scalpel Fast file carver working on disk images http://www.digitalforensicssolutions.com/Scalpel/&lt;br /&gt;
* afftools - Utilities for afflib http://afflib.org/&lt;br /&gt;
* examiner - Utility to disassemble and comment foreign executable binaries&lt;br /&gt;
* firstaidkit - System Rescue Tool&lt;br /&gt;
* foremost - Recover files by &amp;quot;carving&amp;quot; them from a raw disk&lt;br /&gt;
* hexedit - A hexadecimal file viewer and editor&lt;br /&gt;
* ntfs-3g - Linux NTFS userspace driver&lt;br /&gt;
* ntfsprogs - NTFS filesystem libraries and utilities&lt;br /&gt;
* scanmem - Simple interactive debugging utility&lt;br /&gt;
* sleuthkit - The Sleuth Kit (TSK)&lt;br /&gt;
* srm - Secure file deletion&lt;br /&gt;
* unhide - Tool to find hidden processes and TCP/UDP ports from rootkits&lt;br /&gt;
&lt;br /&gt;
chntpw&lt;br /&gt;
samdump2  http://sourceforge.net/projects/ophcrack/files/samdump2/2.0.1/&lt;br /&gt;
creddump http://code.google.com/p/creddump/&lt;br /&gt;
Hydra&lt;br /&gt;
Medusa&lt;br /&gt;
volatility An advanced memory forensics framework http://code.google.com/p/volatility/&lt;br /&gt;
pdfcrack A Password Recovery Tool for PDF files http://pdfcrack.sourceforge.net/&lt;br /&gt;
http://code.google.com/p/logkeys/&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reconnaissance ==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
! URL&lt;br /&gt;
|-&lt;br /&gt;
| arpalert&lt;br /&gt;
| Monitor ARP changes in ethernet networks&lt;br /&gt;
| http://www.arpalert.org&lt;br /&gt;
|-&lt;br /&gt;
| arpon&lt;br /&gt;
| ARP handler inspection&lt;br /&gt;
| http://arpon.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| dnsenum&lt;br /&gt;
| A tool to enumerate DNS info about domains&lt;br /&gt;
| http://code.google.com/p/dnsenum/&lt;br /&gt;
|-&lt;br /&gt;
| halberd&lt;br /&gt;
| A tool to discover HTTP load balancers&lt;br /&gt;
| http://halberd.superadditive.com/&lt;br /&gt;
|-&lt;br /&gt;
| scanssh&lt;br /&gt;
| Fast SSH server and open proxy scanner&lt;br /&gt;
| http://monkey.org/~provos/scanssh/&lt;br /&gt;
|-&lt;br /&gt;
| ngrep&lt;br /&gt;
| Network layer grep tool&lt;br /&gt;
| http://ngrep.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| netsniff-ng&lt;br /&gt;
| A performant Linux network analyzer and networking toolkit&lt;br /&gt;
| http://netsniff-ng.org/&lt;br /&gt;
|-&lt;br /&gt;
| scapy&lt;br /&gt;
| Interactive packet manipulation tool and network scanner&lt;br /&gt;
| http://www.secdev.org/projects/scapy/&lt;br /&gt;
|-&lt;br /&gt;
| socat&lt;br /&gt;
| Bidirectional data relay between two data channels (&#039;netcat++&#039;)&lt;br /&gt;
| http://www.dest-unreach.org/socat/&lt;br /&gt;
|-&lt;br /&gt;
| tcpdump&lt;br /&gt;
| A network traffic monitoring tool&lt;br /&gt;
| http://www.tcpdump.org/&lt;br /&gt;
|-&lt;br /&gt;
| tcptrack&lt;br /&gt;
| Displays information about tcp connections on a network interface&lt;br /&gt;
| http://www.rhythm.cx/~steve/devel/tcptrack/&lt;br /&gt;
|-&lt;br /&gt;
| tcpflow&lt;br /&gt;
| A tool for monitoring, capturing and storing TCP connections flows&lt;br /&gt;
| http://www.circlemud.org/~jelson/software/tcpflow/&lt;br /&gt;
|-&lt;br /&gt;
| tcpproxy&lt;br /&gt;
| Transparent TCP Proxy&lt;br /&gt;
| http://www.quietsche-entchen.de/cgi-bin/wiki.cgi/proxies/TcpProxy&lt;br /&gt;
|-&lt;br /&gt;
| etherdump&lt;br /&gt;
| An extremely small packet sniffer&lt;br /&gt;
| http://freshmeat.net/projects/etherdump/&lt;br /&gt;
|-&lt;br /&gt;
| netdiscover&lt;br /&gt;
| A network address discovering tool&lt;br /&gt;
| http://sourceforge.net/projects/netdiscover/&lt;br /&gt;
|-&lt;br /&gt;
| nmap&lt;br /&gt;
| A network exploration tool and security/port scanner&lt;br /&gt;
| http://nmap.org&lt;br /&gt;
|-&lt;br /&gt;
| arpwatch&lt;br /&gt;
| An ethernet monitoring program &lt;br /&gt;
| http://www-nrg.ee.lbl.gov/&lt;br /&gt;
|-&lt;br /&gt;
| nfswatch&lt;br /&gt;
| An NFS traffic monitoring tool&lt;br /&gt;
| http://nfswatch.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| p0f&lt;br /&gt;
| Passive traffic fingerprinting tool&lt;br /&gt;
| http://lcamtuf.coredump.cx/p0f3/&lt;br /&gt;
|-&lt;br /&gt;
| hping3&lt;br /&gt;
| A ping-like TCP/IP packet assembler/analyzer&lt;br /&gt;
| http://www.hping.org&lt;br /&gt;
|-&lt;br /&gt;
| sslscan&lt;br /&gt;
| Security assessment tool for SSL&lt;br /&gt;
| http://sourceforge.net/projects/sslscan/&lt;br /&gt;
|-&lt;br /&gt;
| httpry&lt;br /&gt;
| A packet sniffer designed for HTTP traffic&lt;br /&gt;
| http://dumpsterventures.com/jason/httpry&lt;br /&gt;
|-&lt;br /&gt;
| bannergrab&lt;br /&gt;
| A banner grabbing tool&lt;br /&gt;
| http://sourceforge.net/projects/bannergrab&lt;br /&gt;
|-&lt;br /&gt;
| dnstop&lt;br /&gt;
| A DNS traffic capture utility&lt;br /&gt;
| http://dns.measurement-factory.com/tools/dnstop/&lt;br /&gt;
|-&lt;br /&gt;
| flunym0us&lt;br /&gt;
| A vulnerability scanner for wordpress and moodle&lt;br /&gt;
| http://code.google.com/p/flunym0us/&lt;br /&gt;
|-&lt;br /&gt;
| swaks&lt;br /&gt;
| A transaction-oriented SMTP test tool&lt;br /&gt;
| http://www.jetmore.org/john/code/swaks/&lt;br /&gt;
|-&lt;br /&gt;
| onesixtyone&lt;br /&gt;
| An efficient SNMP scanner&lt;br /&gt;
| http://www.phreedom.org/software/onesixtyone/&lt;br /&gt;
|-&lt;br /&gt;
| mitmproxy&lt;br /&gt;
| An interactive SSL-capable intercepting HTTP proxy&lt;br /&gt;
| http://www.mitmproxy.org/&lt;br /&gt;
|-&lt;br /&gt;
| hexinject&lt;br /&gt;
| A very versatile packet injector and sniffer&lt;br /&gt;
| http://hexinject.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| [[Setting up OpenVAS9|openvas]]&lt;br /&gt;
| Vulnerability scanner and manager&lt;br /&gt;
| http://www.openvas.org/src-doc/openvas-manager/index.html&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ToDo&lt;br /&gt;
whatweb&lt;br /&gt;
A website fingerprinter&lt;br /&gt;
http://www.morningstarsecurity.com/research/whatweb&lt;br /&gt;
&lt;br /&gt;
blindelephant&lt;br /&gt;
A web application fingerprinter&lt;br /&gt;
http://blindelephant.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
dpkt&lt;br /&gt;
python packet creation / parsing library &lt;br /&gt;
http://code.google.com/p/dpkt/&lt;br /&gt;
&lt;br /&gt;
Wireplay&lt;br /&gt;
A minimalist approach to replay pcap dumped TCP sessions with modification as required. &lt;br /&gt;
http://code.google.com/p/wireplay/&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| ike-scan&lt;br /&gt;
| An IPsec VPN scanning, fingerprinting, and testing tool&lt;br /&gt;
| http://www.nta-monitor.com/tools/ike-scan/&lt;br /&gt;
&lt;br /&gt;
http://inguma.sourceforge.net/&lt;br /&gt;
* nuttcp http://www.nuttcp.net&lt;br /&gt;
* argus http://qosient.com/argus/&lt;br /&gt;
* tcpick http://tcpick.sourceforge.net/&lt;br /&gt;
* tcpreen -- A TCP/IP re-engineering and monitoring program &lt;br /&gt;
* tcpdump -- A network traffic monitoring tool&lt;br /&gt;
* tcpflow -- Network traffic recorder&lt;br /&gt;
* tcpick -- A tcp stream sniffer, tracker and capturer&lt;br /&gt;
* tcping -- Check of TCP connection to a given IP/Port&lt;br /&gt;
* tcpjunk -- TCP protocols testing tool&lt;br /&gt;
* tcpreplay -- Replay captured network traffic&lt;br /&gt;
* tcptraceroute -- A traceroute implementation using TCP packets&lt;br /&gt;
* tcptrack -- Displays information about tcp connections on a network interface&lt;br /&gt;
* tcputils -- Utilities for TCP programming in shell-scripts&lt;br /&gt;
* tcp_wrappers -- A security tool which acts as a wrapper for TCP daemons&lt;br /&gt;
* tcpxtract -- Tool for extracting files from network traffic&lt;br /&gt;
* ttcp A tool for testing TCP connections http://www.pcausa.com/Utilities/pcattcp.htm&lt;br /&gt;
* unicornscan http://www.unicornscan.org/&lt;br /&gt;
* dsniff - Tools for network auditing and penetration testing &lt;br /&gt;
* httpry http://dumpsterventures.com/jason/httpry/&lt;br /&gt;
* justniffer&lt;br /&gt;
* dietsniff&lt;br /&gt;
* Nast http://nast.berlios.de/&lt;br /&gt;
* brutessh http://www.edge-security.com/brutessh.php&lt;br /&gt;
* ettercap http://ettercap.sourceforge.net/ A network traffic sniffer/analyser&lt;br /&gt;
* icmpshell A tool that only uses ICMP for connections http://icmpshell.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
http://code.google.com/p/yapscan/&lt;br /&gt;
egressor http://packetfactory.openwall.net/projects/egressor/&lt;br /&gt;
arpoc http://www.phenoelit.org/arpoc/index.html&lt;br /&gt;
loadbalancer-finder http://code.google.com/p/loadbalancer-finder/&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Application Testing==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
! URL&lt;br /&gt;
|-&lt;br /&gt;
| wbox&lt;br /&gt;
| HTTP testing tool and configuration-less HTTP server&lt;br /&gt;
| http://www.hping.org/wbox/&lt;br /&gt;
|-&lt;br /&gt;
| slowhttptest&lt;br /&gt;
| An application Layer DoS attack simulator&lt;br /&gt;
| http://code.google.com/p/slowhttptest&lt;br /&gt;
|-&lt;br /&gt;
| nikto&lt;br /&gt;
| A web application security scanner&lt;br /&gt;
| https://www.cirt.net/Nikto2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
|-&lt;br /&gt;
| arachni&lt;br /&gt;
| Web application security scanner framework&lt;br /&gt;
| http://arachni-scanner.com/&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
wpscan http://wpscan.org/ A vulnerability scanner for WordPress installations &lt;br /&gt;
&lt;br /&gt;
http://www.rootkit.nl/projects/lynis.html&lt;br /&gt;
wapiti http://www.ict-romulus.eu/web/wapiti/home&lt;br /&gt;
* proxystrike http://www.edge-security.com/proxystrike.php&lt;br /&gt;
* sqlmap http://sqlmap.sourceforge.net/&lt;br /&gt;
* ratproxy - A passive web application security assessment tool &lt;br /&gt;
* sqlninja&lt;br /&gt;
* fimap A little tool for local and remote file inclusion auditing and exploitation http://code.google.com/p/fimap/&lt;br /&gt;
* burpproxy&lt;br /&gt;
mysqlenum An automatic blind SQL injection tool&lt;br /&gt;
mole themole.nasel.com.ar&lt;br /&gt;
http://motomastyle.com/pyloris/&lt;br /&gt;
http://www.buck-security.org/buck-security.html&lt;br /&gt;
http://freecode.com/projects/trusion&lt;br /&gt;
http://www.parosproxy.org/&lt;br /&gt;
BeEF   http://beefproject.com/&lt;br /&gt;
http://code.google.com/p/zaproxy/&lt;br /&gt;
http://code.google.com/p/webapptools/&lt;br /&gt;
slowhttptest An application Layer DoS attack simulator  http://code.google.com/p/slowhttptest/&lt;br /&gt;
http://code.google.com/p/ghost-phisher/&lt;br /&gt;
http://code.google.com/p/fern-wifi-cracker/&lt;br /&gt;
http://code.google.com/p/intrinsec-xmlrpc-scanner/&lt;br /&gt;
http://code.google.com/p/gsploit/&lt;br /&gt;
patator A multi-purpose brute-forcer, with a modular design and a flexible usage http://code.google.com/p/patator/ &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Network statistics ==&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
! URL&lt;br /&gt;
|-&lt;br /&gt;
| iperf&lt;br /&gt;
| Tool to measure IP bandwidth using UDP or TCP&lt;br /&gt;
| http://iperf.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| iptraf-ng&lt;br /&gt;
| A console-based network monitoring utility &lt;br /&gt;
| https://fedorahosted.org/iptraf-ng/&lt;br /&gt;
|-&lt;br /&gt;
| iptop&lt;br /&gt;
| Command line tool that displays bandwidth usage on an interface &lt;br /&gt;
| http://www.ex-parrot.com/~pdw/iftop/&lt;br /&gt;
|-&lt;br /&gt;
| fping&lt;br /&gt;
| A utility to ping multiple hosts at once&lt;br /&gt;
| http://fping.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| mtr&lt;br /&gt;
| Full screen ncurses traceroute tool&lt;br /&gt;
| http://www.bitwizard.nl/mtr/&lt;br /&gt;
|-&lt;br /&gt;
| speedometer&lt;br /&gt;
| Measure and display the rate of data across a network connection or data being stored in a file&lt;br /&gt;
| http://excess.org/speedometer/&lt;br /&gt;
|-&lt;br /&gt;
| nfdump&lt;br /&gt;
| The nfdump tools collect and process netflow data on the command line&lt;br /&gt;
| http://nfdump.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| nethogs&lt;br /&gt;
| Top-like monitor for network traffic&lt;br /&gt;
| http://raboof.github.io/nethogs/&lt;br /&gt;
|-&lt;br /&gt;
| iptstate&lt;br /&gt;
| Top-like interface to netfilter connection-tracking table&lt;br /&gt;
| http://www.phildev.net/iptstate/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
EthStatus&lt;br /&gt;
&lt;br /&gt;
nttcp &lt;br /&gt;
netio http://www.ars.de/ars/ars.nsf/docs/netio&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Misc tools ==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
! URL&lt;br /&gt;
|-&lt;br /&gt;
| bash-completion&lt;br /&gt;
| Command-line tab-completion for bash&lt;br /&gt;
| http://bash-completion.alioth.debian.org/&lt;br /&gt;
|-&lt;br /&gt;
| clamav&lt;br /&gt;
| An anti-virus toolkit for UNIX&lt;br /&gt;
| http://www.clamav.net&lt;br /&gt;
|-&lt;br /&gt;
| p7zip&lt;br /&gt;
| A command-line port of the 7zip compression utility&lt;br /&gt;
| http://p7zip.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| nano&lt;br /&gt;
| A simple ncurses text editor&lt;br /&gt;
| http://www.nano-editor.org/&lt;br /&gt;
|-&lt;br /&gt;
| rsync&lt;br /&gt;
| A file transfer program to keep remote files in sync&lt;br /&gt;
| http://rsync.samba.org/&lt;br /&gt;
|-&lt;br /&gt;
| screen&lt;br /&gt;
| A terminal multiplexer, used to multiplex several virtual consoles. Similar to &amp;quot;tmux&amp;quot; below&lt;br /&gt;
| http://www.gnu.org/software/screen/&lt;br /&gt;
|-&lt;br /&gt;
| tmux&lt;br /&gt;
| A terminal multiplexer, used to multiplex several virtual consoles. Similar to &amp;quot;screen&amp;quot; above&lt;br /&gt;
| https://tmux.github.io/&lt;br /&gt;
|-&lt;br /&gt;
| multitail&lt;br /&gt;
| A tool to view one or multiple files&lt;br /&gt;
| http://www.vanheusden.com/multitail&lt;br /&gt;
|-&lt;br /&gt;
| shed&lt;br /&gt;
| A simple hex editor&lt;br /&gt;
| http://shed.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| e2fsprogs&lt;br /&gt;
| Standard Ext2/3/4 filesystem utilities&lt;br /&gt;
| http://e2fsprogs.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| openssh&lt;br /&gt;
| An open source implementation of SSH protocol versions 1 and 2&lt;br /&gt;
| http://www.openssh.org/&lt;br /&gt;
|-&lt;br /&gt;
| passwdgen&lt;br /&gt;
| A random password generator&lt;br /&gt;
| http://code.google.com/p/passwdgen/&lt;br /&gt;
|-&lt;br /&gt;
| partclone&lt;br /&gt;
| Back up and restore used-blocks of a partition &lt;br /&gt;
| http://partclone.org&lt;br /&gt;
|-&lt;br /&gt;
| sshguard&lt;br /&gt;
| Log monitor that blocks with iptables on bad behaviour&lt;br /&gt;
| http://www.sshguard.net/download/&lt;br /&gt;
|-&lt;br /&gt;
| proxychains&lt;br /&gt;
| A tool that forces any TCP connection through proxies&lt;br /&gt;
| http://proxychains.sourceforge.net&lt;br /&gt;
|-&lt;br /&gt;
| knock&lt;br /&gt;
| A simple port-knocking daemon&lt;br /&gt;
| http://www.zeroflux.org/projects/knock&lt;br /&gt;
|-&lt;br /&gt;
| logcheck&lt;br /&gt;
| A simple utility which is designed to allow a system administrator to view the logfiles&lt;br /&gt;
| http://www.logcheck.org&lt;br /&gt;
|-&lt;br /&gt;
| mc&lt;br /&gt;
| A visual file manager&lt;br /&gt;
| https://www.midnight-commander.org/&lt;br /&gt;
|-&lt;br /&gt;
| makepasswd&lt;br /&gt;
| Generates (pseudo-)random passwords of a desired length&lt;br /&gt;
| http://people.defora.org/~khorben/projects/makepasswd/&lt;br /&gt;
|-&lt;br /&gt;
| lnav&lt;br /&gt;
| A curses-based tool for viewing and analyzing log files&lt;br /&gt;
| http://lnav.org&lt;br /&gt;
|-&lt;br /&gt;
| goaccess&lt;br /&gt;
| A real-time web log analyzer and interactive viewer&lt;br /&gt;
| http://goaccess.prosoftcorp.com/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
| macchanger&lt;br /&gt;
| An utility for viewing/manipulating the MAC address of network interfaces&lt;br /&gt;
| http://www.alobbs.com/macchanger&lt;br /&gt;
&lt;br /&gt;
| denyhosts &lt;br /&gt;
| A script to help thwart ssh server attacks&lt;br /&gt;
| http://denyhosts.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
| fwknop&lt;br /&gt;
| A cobination of port knocking and passive OS fingerprinting&lt;br /&gt;
| http://www.cipherdyne.org/fwknop/&lt;br /&gt;
&lt;br /&gt;
chkrootkit&lt;br /&gt;
bonesi http://code.google.com/p/bonesi/&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== VoIP==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
! URL&lt;br /&gt;
|-&lt;br /&gt;
| sipp&lt;br /&gt;
| A test tool / traffic generator for the SIP protocol&lt;br /&gt;
| http://sipp.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| voiphopper&lt;br /&gt;
| A VLAN Hop security test&lt;br /&gt;
| http://voiphopper.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| sipvicious&lt;br /&gt;
| Tools for auditing SIP based VoIP systems&lt;br /&gt;
| http://code.google.com/p/sipvicious/&lt;br /&gt;
|-&lt;br /&gt;
| sipcrack&lt;br /&gt;
| A SIP protocol login cracker&lt;br /&gt;
| http://packages.debian.org/lenny/sipcrack&lt;br /&gt;
|-&lt;br /&gt;
| sipsak&lt;br /&gt;
| SIP swiss army knife&lt;br /&gt;
| http://sipsak.org/&lt;br /&gt;
|-&lt;br /&gt;
| smap&lt;br /&gt;
| A simple scanner for SIP enabled devices&lt;br /&gt;
| http://www.wormulon.net/smap&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
|-&lt;br /&gt;
| oreka&lt;br /&gt;
| An audio stream recording and retrieval system&lt;br /&gt;
| http://oreka.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| sipflanker&lt;br /&gt;
| Finder for vulnerable Web GUIs deployed by IP phones and PBXs&lt;br /&gt;
| http://code.google.com/p/sipflanker/&lt;br /&gt;
&lt;br /&gt;
ucsniff A VoIP and IP video security assessment tool http://ucsniff.sourceforge.net/&lt;br /&gt;
videosharf&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Wireless ==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
! URL&lt;br /&gt;
|-&lt;br /&gt;
| weplab&lt;br /&gt;
| Analyzing WEP encryption security on wireless networks&lt;br /&gt;
| http://weplab.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| kismet&lt;br /&gt;
| A WLAN detector, sniffer, and IDS&lt;br /&gt;
| http://www.kismetwireless.org/&lt;br /&gt;
|-&lt;br /&gt;
| cowpatty&lt;br /&gt;
| Attacking WPA/WPA2-PSK exchanges&lt;br /&gt;
| http://www.willhackforsushi.com/Cowpatty.html&lt;br /&gt;
|-&lt;br /&gt;
| wavemon&lt;br /&gt;
| Ncurses-based monitoring application for wireless network devices&lt;br /&gt;
| http://eden-feed.erg.abdn.ac.uk/wavemon/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Todo&lt;br /&gt;
|-&lt;br /&gt;
| aircrack-ng&lt;br /&gt;
| 802.11 (wireless) sniffer and WEP/WPA-PSK key cracker &lt;br /&gt;
| http://www.aircrack-ng.org/&lt;br /&gt;
&lt;br /&gt;
* pgpry PGP private key recovery http://pgpry.sourceforge.net/&lt;br /&gt;
* airsnarf A rogue AP setup utility http://airsnarf.shmoo.com/&lt;br /&gt;
* lorcon http://802.11ninja.net/lorcon/ A library for injecting 802.11 (WLAN) frames&lt;br /&gt;
quickset A suite of tools designed to setup the basics for a PenTest http://code.google.com/p/quickset/&lt;br /&gt;
wifite An automated wireless auditor http://code.google.com/p/wifite/ &lt;br /&gt;
reaver Brute force attack against Wifi Protected Setup http://code.google.com/p/reaver-wps/&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Intrusion detection ==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
! URL&lt;br /&gt;
|-&lt;br /&gt;
| nebula&lt;br /&gt;
| An Intrusion Signature Generator&lt;br /&gt;
| http://nebula.carnivore.it/&lt;br /&gt;
|-&lt;br /&gt;
| snort&lt;br /&gt;
| A network intrusion prevention and detection system&lt;br /&gt;
| http://www.snort.org/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
aide| Intrusion detection environment&lt;br /&gt;
chkrootkit| Tool to locally check for signs of a rootkit&lt;br /&gt;
honeyd| Honeypot daemon&lt;br /&gt;
labrea| Tarpit (slow to a crawl) worms and port scanners&lt;br /&gt;
pads| Passive Asset Detection System&lt;br /&gt;
rkhunter| A host-based tool to scan for rootkits, backdoors and local exploits&lt;br /&gt;
tiger| Security auditing on UNIX systems| http://www.nongnu.org/tiger/&lt;br /&gt;
prelude-lml| The prelude log analyzer&lt;br /&gt;
prewikka| Graphical front-end analysis console for the Prelude Hybrid IDS * Framework&lt;br /&gt;
prelude-manager| Prelude-Manager&lt;br /&gt;
nemesis|A TCP/IP packet injection tool| http://nemesis.sourceforge.net/&lt;br /&gt;
inundator| An IDS detection false positives generator| http://inundator.sourceforge.net/&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
More tools:&lt;br /&gt;
http://sectools.org/tag/new/&lt;br /&gt;
http://www.voipsa.org/Resources/tools.php&lt;br /&gt;
http://securitytube-tools.net/index.php?title=Welcome_to_SecurityTube_Tools&lt;br /&gt;
http://www.goitworld.com/top-15-free-sql-injection-scanners/&lt;br /&gt;
 --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:ISO]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Alpine_security&amp;diff=14162</id>
		<title>Alpine security</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Alpine_security&amp;diff=14162"/>
		<updated>2017-12-02T19:25:16Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* Misc tools */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Note|This is work in progress. Not all packages are available at the moment.}}&lt;br /&gt;
&lt;br /&gt;
== Basics ==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
! URL&lt;br /&gt;
|-&lt;br /&gt;
| alpine-base&lt;br /&gt;
| Alpine base package&lt;br /&gt;
| http://alpinelinux.org&lt;br /&gt;
|-&lt;br /&gt;
| alpine-mirrors&lt;br /&gt;
| List of Alpine Linux Mirrors&lt;br /&gt;
| http://alpinelinux.org/&lt;br /&gt;
|-&lt;br /&gt;
| bkeymaps&lt;br /&gt;
| Binary keymaps for busybox&lt;br /&gt;
| http://dev.alpinelinux.org/alpine/bkeymaps&lt;br /&gt;
|-&lt;br /&gt;
| network-extras&lt;br /&gt;
| Meta package to pull in vlan, bonding, bridge and wifi support&lt;br /&gt;
| http://alpinelinux.org&lt;br /&gt;
|-&lt;br /&gt;
| openssl&lt;br /&gt;
| Toolkit for SSL v2/v3 and TLS v1&lt;br /&gt;
| http://openssl.org&lt;br /&gt;
|-&lt;br /&gt;
| tzdata&lt;br /&gt;
| Timezone data&lt;br /&gt;
| http://www.twinsun.com/tz/tz-link.htm&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Code Analysis ==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
! URL&lt;br /&gt;
|-&lt;br /&gt;
| rpmlint&lt;br /&gt;
| A tool for checking common errors in RPM packages&lt;br /&gt;
| http://rpmlint.zarb.org&lt;br /&gt;
|-&lt;br /&gt;
| pylint&lt;br /&gt;
| Analyzes Python code looking for bugs and signs of poor quality&lt;br /&gt;
| http://pypi.python.org/pypi/pylint&lt;br /&gt;
|-&lt;br /&gt;
| flawfinder&lt;br /&gt;
| Examines C/C++ source code for security flaws&lt;br /&gt;
| http://www.dwheeler.com/flawfinder/&lt;br /&gt;
|-&lt;br /&gt;
| rats&lt;br /&gt;
| A tool to find security related programming errors&lt;br /&gt;
| https://www.fortify.com/ssa-elements/threat-intelligence/rats.html&lt;br /&gt;
|-&lt;br /&gt;
| pychecker&lt;br /&gt;
| A analyser for python source code&lt;br /&gt;
| http://pychecker.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| pyflakes&lt;br /&gt;
| A passive checker of Python programs&lt;br /&gt;
| https://launchpad.net/pyflakes&lt;br /&gt;
|-&lt;br /&gt;
| strace&lt;br /&gt;
| A useful diagnositic, instructional, and debugging tool&lt;br /&gt;
| http://sourceforge.net/projects/strace/&lt;br /&gt;
|-&lt;br /&gt;
| netsink&lt;br /&gt;
| A Network Sinkhole for Isolated Malware Analysis&lt;br /&gt;
| https://github.com/shendo/netsink&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
Todo&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| splint&lt;br /&gt;
| An implementation of the lint program &lt;br /&gt;
| http://www.splint.org/&lt;br /&gt;
|-&lt;br /&gt;
| valgrind&lt;br /&gt;
| A tool for finding memory-management problems&lt;br /&gt;
| http://valgrind.org/&lt;br /&gt;
|-&lt;br /&gt;
| pscan&lt;br /&gt;
| Limited problem scanner for C source files&lt;br /&gt;
|&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Forensics / Data recovery tools ==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
! URL&lt;br /&gt;
|-&lt;br /&gt;
| dc3dd&lt;br /&gt;
| Patched version of GNU dd for use in computer forensics &lt;br /&gt;
| http://dc3dd.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| ddrescue&lt;br /&gt;
| Data recovery tool for block devices with errors &lt;br /&gt;
| http://www.gnu.org/s/ddrescue/ddrescue.html&lt;br /&gt;
|-&lt;br /&gt;
| testdisk&lt;br /&gt;
| A powerful free data recovery software&lt;br /&gt;
| http://www.cgsecurity.org/wiki/TestDisk&lt;br /&gt;
|-&lt;br /&gt;
| scrub&lt;br /&gt;
| Disk scrubbing program&lt;br /&gt;
| http://code.google.com/p/diskscrub/&lt;br /&gt;
|-&lt;br /&gt;
| ncdu&lt;br /&gt;
| A curses-based version of the well-known &amp;quot;du&amp;quot;&lt;br /&gt;
| http://dev.yorhel.nl/ncdu&lt;br /&gt;
|-&lt;br /&gt;
| htop&lt;br /&gt;
| An interactive process viewer for Linux&lt;br /&gt;
| http://htop.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| mac-robber&lt;br /&gt;
| A tool that collects data from allocated files in a mounted file system&lt;br /&gt;
| http://www.sleuthkit.org/mac-robber/desc.php&lt;br /&gt;
|-&lt;br /&gt;
| wipe&lt;br /&gt;
| Tool for securely erasing files from magnetic media&lt;br /&gt;
| http://lambda-diode.com/software/wipe/&lt;br /&gt;
|-&lt;br /&gt;
| nwipe&lt;br /&gt;
| Securely erase disks using a variety of recognized methods&lt;br /&gt;
| http://nwipe.sourceforge.net&lt;br /&gt;
|-&lt;br /&gt;
| jhead&lt;br /&gt;
| An Exif jpeg header manipulation tool&lt;br /&gt;
| http://www.sentex.net/~mwandel/jhead/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ToDo&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| aimage&lt;br /&gt;
| Advanced Disk Imager&lt;br /&gt;
| http://www.afflib.org&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| fiwalk&lt;br /&gt;
| Batch analysis of a disk image&lt;br /&gt;
| http://www.afflib.org&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| ftimes&lt;br /&gt;
| A system baselining and evidence collection too&lt;br /&gt;
| http://ftimes.sourceforge.net/FTimes/&lt;br /&gt;
&lt;br /&gt;
http://sourceforge.net/projects/cdpr/&lt;br /&gt;
| rarcrack&lt;br /&gt;
| http://rarcrack.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
| extcarve&lt;br /&gt;
| safecopy &lt;br /&gt;
| A data recovery tool&lt;br /&gt;
| http://safecopy.sourceforge.net/&lt;br /&gt;
* scalpel Fast file carver working on disk images http://www.digitalforensicssolutions.com/Scalpel/&lt;br /&gt;
* afftools - Utilities for afflib http://afflib.org/&lt;br /&gt;
* examiner - Utility to disassemble and comment foreign executable binaries&lt;br /&gt;
* firstaidkit - System Rescue Tool&lt;br /&gt;
* foremost - Recover files by &amp;quot;carving&amp;quot; them from a raw disk&lt;br /&gt;
* hexedit - A hexadecimal file viewer and editor&lt;br /&gt;
* ntfs-3g - Linux NTFS userspace driver&lt;br /&gt;
* ntfsprogs - NTFS filesystem libraries and utilities&lt;br /&gt;
* scanmem - Simple interactive debugging utility&lt;br /&gt;
* sleuthkit - The Sleuth Kit (TSK)&lt;br /&gt;
* srm - Secure file deletion&lt;br /&gt;
* unhide - Tool to find hidden processes and TCP/UDP ports from rootkits&lt;br /&gt;
&lt;br /&gt;
chntpw&lt;br /&gt;
samdump2  http://sourceforge.net/projects/ophcrack/files/samdump2/2.0.1/&lt;br /&gt;
creddump http://code.google.com/p/creddump/&lt;br /&gt;
Hydra&lt;br /&gt;
Medusa&lt;br /&gt;
volatility An advanced memory forensics framework http://code.google.com/p/volatility/&lt;br /&gt;
pdfcrack A Password Recovery Tool for PDF files http://pdfcrack.sourceforge.net/&lt;br /&gt;
http://code.google.com/p/logkeys/&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Reconnaissance ==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
! URL&lt;br /&gt;
|-&lt;br /&gt;
| arpalert&lt;br /&gt;
| Monitor ARP changes in ethernet networks&lt;br /&gt;
| http://www.arpalert.org&lt;br /&gt;
|-&lt;br /&gt;
| arpon&lt;br /&gt;
| ARP handler inspection&lt;br /&gt;
| http://arpon.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| dnsenum&lt;br /&gt;
| A tool to enumerate DNS info about domains&lt;br /&gt;
| http://code.google.com/p/dnsenum/&lt;br /&gt;
|-&lt;br /&gt;
| halberd&lt;br /&gt;
| A tool to discover HTTP load balancers&lt;br /&gt;
| http://halberd.superadditive.com/&lt;br /&gt;
|-&lt;br /&gt;
| scanssh&lt;br /&gt;
| Fast SSH server and open proxy scanner&lt;br /&gt;
| http://monkey.org/~provos/scanssh/&lt;br /&gt;
|-&lt;br /&gt;
| ngrep&lt;br /&gt;
| Network layer grep tool&lt;br /&gt;
| http://ngrep.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| netsniff-ng&lt;br /&gt;
| A performant Linux network analyzer and networking toolkit&lt;br /&gt;
| http://netsniff-ng.org/&lt;br /&gt;
|-&lt;br /&gt;
| scapy&lt;br /&gt;
| Interactive packet manipulation tool and network scanner&lt;br /&gt;
| http://www.secdev.org/projects/scapy/&lt;br /&gt;
|-&lt;br /&gt;
| socat&lt;br /&gt;
| Bidirectional data relay between two data channels (&#039;netcat++&#039;)&lt;br /&gt;
| http://www.dest-unreach.org/socat/&lt;br /&gt;
|-&lt;br /&gt;
| tcpdump&lt;br /&gt;
| A network traffic monitoring tool&lt;br /&gt;
| http://www.tcpdump.org/&lt;br /&gt;
|-&lt;br /&gt;
| tcptrack&lt;br /&gt;
| Displays information about tcp connections on a network interface&lt;br /&gt;
| http://www.rhythm.cx/~steve/devel/tcptrack/&lt;br /&gt;
|-&lt;br /&gt;
| tcpflow&lt;br /&gt;
| A tool for monitoring, capturing and storing TCP connections flows&lt;br /&gt;
| http://www.circlemud.org/~jelson/software/tcpflow/&lt;br /&gt;
|-&lt;br /&gt;
| tcpproxy&lt;br /&gt;
| Transparent TCP Proxy&lt;br /&gt;
| http://www.quietsche-entchen.de/cgi-bin/wiki.cgi/proxies/TcpProxy&lt;br /&gt;
|-&lt;br /&gt;
| etherdump&lt;br /&gt;
| An extremely small packet sniffer&lt;br /&gt;
| http://freshmeat.net/projects/etherdump/&lt;br /&gt;
|-&lt;br /&gt;
| netdiscover&lt;br /&gt;
| A network address discovering tool&lt;br /&gt;
| http://sourceforge.net/projects/netdiscover/&lt;br /&gt;
|-&lt;br /&gt;
| nmap&lt;br /&gt;
| A network exploration tool and security/port scanner&lt;br /&gt;
| http://nmap.org&lt;br /&gt;
|-&lt;br /&gt;
| arpwatch&lt;br /&gt;
| An ethernet monitoring program &lt;br /&gt;
| http://www-nrg.ee.lbl.gov/&lt;br /&gt;
|-&lt;br /&gt;
| nfswatch&lt;br /&gt;
| An NFS traffic monitoring tool&lt;br /&gt;
| http://nfswatch.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| p0f&lt;br /&gt;
| Passive traffic fingerprinting tool&lt;br /&gt;
| http://lcamtuf.coredump.cx/p0f3/&lt;br /&gt;
|-&lt;br /&gt;
| hping3&lt;br /&gt;
| A ping-like TCP/IP packet assembler/analyzer&lt;br /&gt;
| http://www.hping.org&lt;br /&gt;
|-&lt;br /&gt;
| sslscan&lt;br /&gt;
| Security assessment tool for SSL&lt;br /&gt;
| http://sourceforge.net/projects/sslscan/&lt;br /&gt;
|-&lt;br /&gt;
| httpry&lt;br /&gt;
| A packet sniffer designed for HTTP traffic&lt;br /&gt;
| http://dumpsterventures.com/jason/httpry&lt;br /&gt;
|-&lt;br /&gt;
| bannergrab&lt;br /&gt;
| A banner grabbing tool&lt;br /&gt;
| http://sourceforge.net/projects/bannergrab&lt;br /&gt;
|-&lt;br /&gt;
| dnstop&lt;br /&gt;
| A DNS traffic capture utility&lt;br /&gt;
| http://dns.measurement-factory.com/tools/dnstop/&lt;br /&gt;
|-&lt;br /&gt;
| flunym0us&lt;br /&gt;
| A vulnerability scanner for wordpress and moodle&lt;br /&gt;
| http://code.google.com/p/flunym0us/&lt;br /&gt;
|-&lt;br /&gt;
| swaks&lt;br /&gt;
| A transaction-oriented SMTP test tool&lt;br /&gt;
| http://www.jetmore.org/john/code/swaks/&lt;br /&gt;
|-&lt;br /&gt;
| onesixtyone&lt;br /&gt;
| An efficient SNMP scanner&lt;br /&gt;
| http://www.phreedom.org/software/onesixtyone/&lt;br /&gt;
|-&lt;br /&gt;
| mitmproxy&lt;br /&gt;
| An interactive SSL-capable intercepting HTTP proxy&lt;br /&gt;
| http://www.mitmproxy.org/&lt;br /&gt;
|-&lt;br /&gt;
| hexinject&lt;br /&gt;
| A very versatile packet injector and sniffer&lt;br /&gt;
| http://hexinject.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| [[Setting up OpenVAS9|openvas]]&lt;br /&gt;
| Vulnerability scanner and manager&lt;br /&gt;
| http://www.openvas.org/src-doc/openvas-manager/index.html&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- ToDo&lt;br /&gt;
whatweb&lt;br /&gt;
A website fingerprinter&lt;br /&gt;
http://www.morningstarsecurity.com/research/whatweb&lt;br /&gt;
&lt;br /&gt;
blindelephant&lt;br /&gt;
A web application fingerprinter&lt;br /&gt;
http://blindelephant.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
dpkt&lt;br /&gt;
python packet creation / parsing library &lt;br /&gt;
http://code.google.com/p/dpkt/&lt;br /&gt;
&lt;br /&gt;
Wireplay&lt;br /&gt;
A minimalist approach to replay pcap dumped TCP sessions with modification as required. &lt;br /&gt;
http://code.google.com/p/wireplay/&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
| ike-scan&lt;br /&gt;
| An IPsec VPN scanning, fingerprinting, and testing tool&lt;br /&gt;
| http://www.nta-monitor.com/tools/ike-scan/&lt;br /&gt;
&lt;br /&gt;
http://inguma.sourceforge.net/&lt;br /&gt;
* nuttcp http://www.nuttcp.net&lt;br /&gt;
* argus http://qosient.com/argus/&lt;br /&gt;
* tcpick http://tcpick.sourceforge.net/&lt;br /&gt;
* tcpreen -- A TCP/IP re-engineering and monitoring program &lt;br /&gt;
* tcpdump -- A network traffic monitoring tool&lt;br /&gt;
* tcpflow -- Network traffic recorder&lt;br /&gt;
* tcpick -- A tcp stream sniffer, tracker and capturer&lt;br /&gt;
* tcping -- Check of TCP connection to a given IP/Port&lt;br /&gt;
* tcpjunk -- TCP protocols testing tool&lt;br /&gt;
* tcpreplay -- Replay captured network traffic&lt;br /&gt;
* tcptraceroute -- A traceroute implementation using TCP packets&lt;br /&gt;
* tcptrack -- Displays information about tcp connections on a network interface&lt;br /&gt;
* tcputils -- Utilities for TCP programming in shell-scripts&lt;br /&gt;
* tcp_wrappers -- A security tool which acts as a wrapper for TCP daemons&lt;br /&gt;
* tcpxtract -- Tool for extracting files from network traffic&lt;br /&gt;
* ttcp A tool for testing TCP connections http://www.pcausa.com/Utilities/pcattcp.htm&lt;br /&gt;
* unicornscan http://www.unicornscan.org/&lt;br /&gt;
* dsniff - Tools for network auditing and penetration testing &lt;br /&gt;
* httpry http://dumpsterventures.com/jason/httpry/&lt;br /&gt;
* justniffer&lt;br /&gt;
* dietsniff&lt;br /&gt;
* Nast http://nast.berlios.de/&lt;br /&gt;
* brutessh http://www.edge-security.com/brutessh.php&lt;br /&gt;
* ettercap http://ettercap.sourceforge.net/ A network traffic sniffer/analyser&lt;br /&gt;
* icmpshell A tool that only uses ICMP for connections http://icmpshell.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
http://code.google.com/p/yapscan/&lt;br /&gt;
egressor http://packetfactory.openwall.net/projects/egressor/&lt;br /&gt;
arpoc http://www.phenoelit.org/arpoc/index.html&lt;br /&gt;
loadbalancer-finder http://code.google.com/p/loadbalancer-finder/&lt;br /&gt;
&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Application Testing==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
! URL&lt;br /&gt;
|-&lt;br /&gt;
| wbox&lt;br /&gt;
| HTTP testing tool and configuration-less HTTP server&lt;br /&gt;
| http://www.hping.org/wbox/&lt;br /&gt;
|-&lt;br /&gt;
| slowhttptest&lt;br /&gt;
| An application Layer DoS attack simulator&lt;br /&gt;
| http://code.google.com/p/slowhttptest&lt;br /&gt;
|-&lt;br /&gt;
| nikto&lt;br /&gt;
| A web application security scanner&lt;br /&gt;
| https://www.cirt.net/Nikto2&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
|-&lt;br /&gt;
| arachni&lt;br /&gt;
| Web application security scanner framework&lt;br /&gt;
| http://arachni-scanner.com/&lt;br /&gt;
| &lt;br /&gt;
&lt;br /&gt;
wpscan http://wpscan.org/ A vulnerability scanner for WordPress installations &lt;br /&gt;
&lt;br /&gt;
http://www.rootkit.nl/projects/lynis.html&lt;br /&gt;
wapiti http://www.ict-romulus.eu/web/wapiti/home&lt;br /&gt;
* proxystrike http://www.edge-security.com/proxystrike.php&lt;br /&gt;
* sqlmap http://sqlmap.sourceforge.net/&lt;br /&gt;
* ratproxy - A passive web application security assessment tool &lt;br /&gt;
* sqlninja&lt;br /&gt;
* fimap A little tool for local and remote file inclusion auditing and exploitation http://code.google.com/p/fimap/&lt;br /&gt;
* burpproxy&lt;br /&gt;
mysqlenum An automatic blind SQL injection tool&lt;br /&gt;
mole themole.nasel.com.ar&lt;br /&gt;
http://motomastyle.com/pyloris/&lt;br /&gt;
http://www.buck-security.org/buck-security.html&lt;br /&gt;
http://freecode.com/projects/trusion&lt;br /&gt;
http://www.parosproxy.org/&lt;br /&gt;
BeEF   http://beefproject.com/&lt;br /&gt;
http://code.google.com/p/zaproxy/&lt;br /&gt;
http://code.google.com/p/webapptools/&lt;br /&gt;
slowhttptest An application Layer DoS attack simulator  http://code.google.com/p/slowhttptest/&lt;br /&gt;
http://code.google.com/p/ghost-phisher/&lt;br /&gt;
http://code.google.com/p/fern-wifi-cracker/&lt;br /&gt;
http://code.google.com/p/intrinsec-xmlrpc-scanner/&lt;br /&gt;
http://code.google.com/p/gsploit/&lt;br /&gt;
patator A multi-purpose brute-forcer, with a modular design and a flexible usage http://code.google.com/p/patator/ &lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Network statistics ==&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
! URL&lt;br /&gt;
|-&lt;br /&gt;
| iperf&lt;br /&gt;
| Tool to measure IP bandwidth using UDP or TCP&lt;br /&gt;
| http://iperf.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| iptraf-ng&lt;br /&gt;
| A console-based network monitoring utility &lt;br /&gt;
| https://fedorahosted.org/iptraf-ng/&lt;br /&gt;
|-&lt;br /&gt;
| iptop&lt;br /&gt;
| Command line tool that displays bandwidth usage on an interface &lt;br /&gt;
| http://www.ex-parrot.com/~pdw/iftop/&lt;br /&gt;
|-&lt;br /&gt;
| fping&lt;br /&gt;
| A utility to ping multiple hosts at once&lt;br /&gt;
| http://fping.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| mtr&lt;br /&gt;
| Full screen ncurses traceroute tool&lt;br /&gt;
| http://www.bitwizard.nl/mtr/&lt;br /&gt;
|-&lt;br /&gt;
| speedometer&lt;br /&gt;
| Measure and display the rate of data across a network connection or data being stored in a file&lt;br /&gt;
| http://excess.org/speedometer/&lt;br /&gt;
|-&lt;br /&gt;
| nfdump&lt;br /&gt;
| The nfdump tools collect and process netflow data on the command line&lt;br /&gt;
| http://nfdump.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| nethogs&lt;br /&gt;
| Top-like monitor for network traffic&lt;br /&gt;
| http://nethogs.sourceforge.net&lt;br /&gt;
|-&lt;br /&gt;
| iptstate&lt;br /&gt;
| Top-like interface to netfilter connection-tracking table&lt;br /&gt;
| http://www.phildev.net/iptstate/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
EthStatus&lt;br /&gt;
&lt;br /&gt;
nttcp &lt;br /&gt;
netio http://www.ars.de/ars/ars.nsf/docs/netio&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Misc tools ==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
! URL&lt;br /&gt;
|-&lt;br /&gt;
| bash-completion&lt;br /&gt;
| Command-line tab-completion for bash&lt;br /&gt;
| http://bash-completion.alioth.debian.org/&lt;br /&gt;
|-&lt;br /&gt;
| clamav&lt;br /&gt;
| An anti-virus toolkit for UNIX&lt;br /&gt;
| http://www.clamav.net&lt;br /&gt;
|-&lt;br /&gt;
| p7zip&lt;br /&gt;
| A command-line port of the 7zip compression utility&lt;br /&gt;
| http://p7zip.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| nano&lt;br /&gt;
| A simple ncurses text editor&lt;br /&gt;
| http://www.nano-editor.org/&lt;br /&gt;
|-&lt;br /&gt;
| rsync&lt;br /&gt;
| A file transfer program to keep remote files in sync&lt;br /&gt;
| http://rsync.samba.org/&lt;br /&gt;
|-&lt;br /&gt;
| screen&lt;br /&gt;
| A terminal multiplexer, used to multiplex several virtual consoles. Similar to &amp;quot;tmux&amp;quot; below&lt;br /&gt;
| http://www.gnu.org/software/screen/&lt;br /&gt;
|-&lt;br /&gt;
| tmux&lt;br /&gt;
| A terminal multiplexer, used to multiplex several virtual consoles. Similar to &amp;quot;screen&amp;quot; above&lt;br /&gt;
| https://tmux.github.io/&lt;br /&gt;
|-&lt;br /&gt;
| multitail&lt;br /&gt;
| A tool to view one or multiple files&lt;br /&gt;
| http://www.vanheusden.com/multitail&lt;br /&gt;
|-&lt;br /&gt;
| shed&lt;br /&gt;
| A simple hex editor&lt;br /&gt;
| http://shed.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| e2fsprogs&lt;br /&gt;
| Standard Ext2/3/4 filesystem utilities&lt;br /&gt;
| http://e2fsprogs.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| openssh&lt;br /&gt;
| An open source implementation of SSH protocol versions 1 and 2&lt;br /&gt;
| http://www.openssh.org/&lt;br /&gt;
|-&lt;br /&gt;
| passwdgen&lt;br /&gt;
| A random password generator&lt;br /&gt;
| http://code.google.com/p/passwdgen/&lt;br /&gt;
|-&lt;br /&gt;
| partclone&lt;br /&gt;
| Back up and restore used-blocks of a partition &lt;br /&gt;
| http://partclone.org&lt;br /&gt;
|-&lt;br /&gt;
| sshguard&lt;br /&gt;
| Log monitor that blocks with iptables on bad behaviour&lt;br /&gt;
| http://www.sshguard.net/download/&lt;br /&gt;
|-&lt;br /&gt;
| proxychains&lt;br /&gt;
| A tool that forces any TCP connection through proxies&lt;br /&gt;
| http://proxychains.sourceforge.net&lt;br /&gt;
|-&lt;br /&gt;
| knock&lt;br /&gt;
| A simple port-knocking daemon&lt;br /&gt;
| http://www.zeroflux.org/projects/knock&lt;br /&gt;
|-&lt;br /&gt;
| logcheck&lt;br /&gt;
| A simple utility which is designed to allow a system administrator to view the logfiles&lt;br /&gt;
| http://www.logcheck.org&lt;br /&gt;
|-&lt;br /&gt;
| mc&lt;br /&gt;
| A visual file manager&lt;br /&gt;
| https://www.midnight-commander.org/&lt;br /&gt;
|-&lt;br /&gt;
| makepasswd&lt;br /&gt;
| Generates (pseudo-)random passwords of a desired length&lt;br /&gt;
| http://people.defora.org/~khorben/projects/makepasswd/&lt;br /&gt;
|-&lt;br /&gt;
| lnav&lt;br /&gt;
| A curses-based tool for viewing and analyzing log files&lt;br /&gt;
| http://lnav.org&lt;br /&gt;
|-&lt;br /&gt;
| goaccess&lt;br /&gt;
| A real-time web log analyzer and interactive viewer&lt;br /&gt;
| http://goaccess.prosoftcorp.com/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
| macchanger&lt;br /&gt;
| An utility for viewing/manipulating the MAC address of network interfaces&lt;br /&gt;
| http://www.alobbs.com/macchanger&lt;br /&gt;
&lt;br /&gt;
| denyhosts &lt;br /&gt;
| A script to help thwart ssh server attacks&lt;br /&gt;
| http://denyhosts.sourceforge.net/&lt;br /&gt;
&lt;br /&gt;
| fwknop&lt;br /&gt;
| A cobination of port knocking and passive OS fingerprinting&lt;br /&gt;
| http://www.cipherdyne.org/fwknop/&lt;br /&gt;
&lt;br /&gt;
chkrootkit&lt;br /&gt;
bonesi http://code.google.com/p/bonesi/&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== VoIP==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
! URL&lt;br /&gt;
|-&lt;br /&gt;
| sipp&lt;br /&gt;
| A test tool / traffic generator for the SIP protocol&lt;br /&gt;
| http://sipp.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| voiphopper&lt;br /&gt;
| A VLAN Hop security test&lt;br /&gt;
| http://voiphopper.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| sipvicious&lt;br /&gt;
| Tools for auditing SIP based VoIP systems&lt;br /&gt;
| http://code.google.com/p/sipvicious/&lt;br /&gt;
|-&lt;br /&gt;
| sipcrack&lt;br /&gt;
| A SIP protocol login cracker&lt;br /&gt;
| http://packages.debian.org/lenny/sipcrack&lt;br /&gt;
|-&lt;br /&gt;
| sipsak&lt;br /&gt;
| SIP swiss army knife&lt;br /&gt;
| http://sipsak.org/&lt;br /&gt;
|-&lt;br /&gt;
| smap&lt;br /&gt;
| A simple scanner for SIP enabled devices&lt;br /&gt;
| http://www.wormulon.net/smap&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
|-&lt;br /&gt;
| oreka&lt;br /&gt;
| An audio stream recording and retrieval system&lt;br /&gt;
| http://oreka.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| sipflanker&lt;br /&gt;
| Finder for vulnerable Web GUIs deployed by IP phones and PBXs&lt;br /&gt;
| http://code.google.com/p/sipflanker/&lt;br /&gt;
&lt;br /&gt;
ucsniff A VoIP and IP video security assessment tool http://ucsniff.sourceforge.net/&lt;br /&gt;
videosharf&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Wireless ==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
! URL&lt;br /&gt;
|-&lt;br /&gt;
| weplab&lt;br /&gt;
| Analyzing WEP encryption security on wireless networks&lt;br /&gt;
| http://weplab.sourceforge.net/&lt;br /&gt;
|-&lt;br /&gt;
| kismet&lt;br /&gt;
| A WLAN detector, sniffer, and IDS&lt;br /&gt;
| http://www.kismetwireless.org/&lt;br /&gt;
|-&lt;br /&gt;
| cowpatty&lt;br /&gt;
| Attacking WPA/WPA2-PSK exchanges&lt;br /&gt;
| http://www.willhackforsushi.com/Cowpatty.html&lt;br /&gt;
|-&lt;br /&gt;
| wavemon&lt;br /&gt;
| Ncurses-based monitoring application for wireless network devices&lt;br /&gt;
| http://eden-feed.erg.abdn.ac.uk/wavemon/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!-- Todo&lt;br /&gt;
|-&lt;br /&gt;
| aircrack-ng&lt;br /&gt;
| 802.11 (wireless) sniffer and WEP/WPA-PSK key cracker &lt;br /&gt;
| http://www.aircrack-ng.org/&lt;br /&gt;
&lt;br /&gt;
* pgpry PGP private key recovery http://pgpry.sourceforge.net/&lt;br /&gt;
* airsnarf A rogue AP setup utility http://airsnarf.shmoo.com/&lt;br /&gt;
* lorcon http://802.11ninja.net/lorcon/ A library for injecting 802.11 (WLAN) frames&lt;br /&gt;
quickset A suite of tools designed to setup the basics for a PenTest http://code.google.com/p/quickset/&lt;br /&gt;
wifite An automated wireless auditor http://code.google.com/p/wifite/ &lt;br /&gt;
reaver Brute force attack against Wifi Protected Setup http://code.google.com/p/reaver-wps/&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Intrusion detection ==&lt;br /&gt;
&lt;br /&gt;
{| cellpadding=&amp;quot;5&amp;quot; border=&amp;quot;1&amp;quot; class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
! Name&lt;br /&gt;
! Description&lt;br /&gt;
! URL&lt;br /&gt;
|-&lt;br /&gt;
| nebula&lt;br /&gt;
| An Intrusion Signature Generator&lt;br /&gt;
| http://nebula.carnivore.it/&lt;br /&gt;
|-&lt;br /&gt;
| snort&lt;br /&gt;
| A network intrusion prevention and detection system&lt;br /&gt;
| http://www.snort.org/&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
aide| Intrusion detection environment&lt;br /&gt;
chkrootkit| Tool to locally check for signs of a rootkit&lt;br /&gt;
honeyd| Honeypot daemon&lt;br /&gt;
labrea| Tarpit (slow to a crawl) worms and port scanners&lt;br /&gt;
pads| Passive Asset Detection System&lt;br /&gt;
rkhunter| A host-based tool to scan for rootkits, backdoors and local exploits&lt;br /&gt;
tiger| Security auditing on UNIX systems| http://www.nongnu.org/tiger/&lt;br /&gt;
prelude-lml| The prelude log analyzer&lt;br /&gt;
prewikka| Graphical front-end analysis console for the Prelude Hybrid IDS * Framework&lt;br /&gt;
prelude-manager| Prelude-Manager&lt;br /&gt;
nemesis|A TCP/IP packet injection tool| http://nemesis.sourceforge.net/&lt;br /&gt;
inundator| An IDS detection false positives generator| http://inundator.sourceforge.net/&lt;br /&gt;
--&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--&lt;br /&gt;
More tools:&lt;br /&gt;
http://sectools.org/tag/new/&lt;br /&gt;
http://www.voipsa.org/Resources/tools.php&lt;br /&gt;
http://securitytube-tools.net/index.php?title=Welcome_to_SecurityTube_Tools&lt;br /&gt;
http://www.goitworld.com/top-15-free-sql-injection-scanners/&lt;br /&gt;
 --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:ISO]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14160</id>
		<title>Nginx as reverse proxy with acme (letsencrypt)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14160"/>
		<updated>2017-12-01T17:23:09Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* Installation */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This setup will allow you to have multiple servers/containers be accessible via a single IP address with the added benefit of centralized generation of letsencrypt certificates and secure https (according to ssllabs ssltest). Be aware you first need to setup regular HTTP server to be able to generate your HTTPS certificates and keys. After you have generated them you can add your HTTPS host based configuration.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
For this howto we need three tools, NGINX, acme-client and openssl (for generating Diffie–Hellman Parameters).&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add nginx acme-client openssl}}&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTP ===&lt;br /&gt;
&lt;br /&gt;
==== Global configuration ====&lt;br /&gt;
&lt;br /&gt;
First step is to refactor our global nginx.conf. Its target at a low traffic http server, to increase performance make changes at top level.&lt;br /&gt;
&lt;br /&gt;
The security settings are taken from https://cipherli.st . Please also read https://hstspreload.org for details about HSTS.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ngnix configuration file&lt;br /&gt;
&lt;br /&gt;
user  nginx;&lt;br /&gt;
&lt;br /&gt;
worker_processes  1; # use &amp;quot;auto&amp;quot; to use all available cores (high performance)&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections  1024; # increase if you need more connections&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    # server_names_hash_bucket_size controls the maximum length&lt;br /&gt;
    # of a virtual host entry (ie the length of the domain name).&lt;br /&gt;
    server_names_hash_bucket_size   64;&lt;br /&gt;
    server_tokens                   off; # hide who we are&lt;br /&gt;
    sendfile                        off; # can cause issues&lt;br /&gt;
&lt;br /&gt;
    # secure nginx according to https://cipherli.st/&lt;br /&gt;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;&lt;br /&gt;
    ssl_prefer_server_ciphers on;&lt;br /&gt;
    ssl_ciphers &amp;quot;EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH&amp;quot;;&lt;br /&gt;
    ssl_ecdh_curve secp384r1; # Requires nginx &amp;gt;= 1.1.0&lt;br /&gt;
    ssl_session_cache shared:SSL:10m;&lt;br /&gt;
    ssl_session_tickets off; # Requires nginx &amp;gt;= 1.5.9&lt;br /&gt;
    ssl_stapling on; # Requires nginx &amp;gt;= 1.3.7&lt;br /&gt;
    ssl_stapling_verify on; # Requires nginx =&amp;gt; 1.3.7&lt;br /&gt;
    resolver 8.8.8.8 8.8.4.4 valid=300s;&lt;br /&gt;
    resolver_timeout 5s;&lt;br /&gt;
    add_header Strict-Transport-Security &amp;quot;max-age=63072000&amp;quot;; # https://hstspreload.org&lt;br /&gt;
    add_header X-Frame-Options DENY;&lt;br /&gt;
    add_header X-Content-Type-Options nosniff;&lt;br /&gt;
&lt;br /&gt;
    ssl_dhparam dhparam.pem;&lt;br /&gt;
&lt;br /&gt;
    # nginx will find this file in the config directory set at nginx build time&lt;br /&gt;
    include mime.types;&lt;br /&gt;
&lt;br /&gt;
    #fallback in case we can&#039;t determine a type&lt;br /&gt;
    default_type application/octet-stream;&lt;br /&gt;
&lt;br /&gt;
    # buffering causes issues&lt;br /&gt;
    proxy_buffering off;&lt;br /&gt;
&lt;br /&gt;
    # include hosts&lt;br /&gt;
    include conf.d/*.conf;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Diffie–Hellman Parameters ====&lt;br /&gt;
&lt;br /&gt;
In the above configuration ssl_dhparam is used so we need to generate a global dhparam file. We want to use a 4096 key size but this can take a very long time. Because of this we are adding an extra option (dsaparam) to generate our dhparam file (see: https://wiki.openssl.org/index.php/Manual:Dhparam(1)#OPTIONS)&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096}}&lt;br /&gt;
&lt;br /&gt;
At this point you should be able to (re)start your nginx server but it will not use any of the security features (yet).&lt;br /&gt;
&lt;br /&gt;
==== Per site configuration files (conf.d) ====&lt;br /&gt;
&lt;br /&gt;
Since Alpine v3.5 we ship NGINX with an default.conf within the /etc/nginx/conf.d directory.&lt;br /&gt;
To add support for another website you can add files with the .conf extension to this directory.&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Common configuration includes ====&lt;br /&gt;
&lt;br /&gt;
If you need to setup multiple proxy setups you can include duplicated data like shown below.&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/proxy_set_header.inc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
proxy_set_header    X-Forwarded-By       $server_addr:$server_port;&lt;br /&gt;
proxy_set_header    X-Forwarded-For      $remote_addr;&lt;br /&gt;
proxy_set_header    X-Forwarded-Proto    $scheme;&lt;br /&gt;
proxy_set_header    Host                 $host;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== acme-client ===&lt;br /&gt;
&lt;br /&gt;
To allow NGINX to support https we need to add certificates and support for ACME (Automatic Certificate Management Environment) responses.&lt;br /&gt;
&lt;br /&gt;
==== ACME responses ====&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/acme.inc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
location /.well-known/acme-challenge {&lt;br /&gt;
    alias /var/www/acme;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add this to your proxy configuration&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Automatic generate certificates ====&lt;br /&gt;
&lt;br /&gt;
Create the following file and make it executable&lt;br /&gt;
 /etc/periodic/weekly/acme-client&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for host in $hosts; do&lt;br /&gt;
        acme-client -a https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf -Nnmv $host &amp;amp;&amp;amp; renew=1&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
[ &amp;quot;$renew&amp;quot; = 1 ] &amp;amp;&amp;amp; rc-service nginx reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script will run weekly to verify if one of your certificates is outdated and renew them when needed.&lt;br /&gt;
&lt;br /&gt;
==== Initial generation of keys and certificates ====&lt;br /&gt;
&lt;br /&gt;
To create your initial certificates and keys you have to run this manually the first time.&lt;br /&gt;
&lt;br /&gt;
 {{Cmd|/etc/periodic/weekly/acme-client}}&lt;br /&gt;
&lt;br /&gt;
Watch the output and see if all goes well. When its finished you should have files in:&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/alpinelinux.nl/fullchain.pem&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/private/alpinelinux.org/privkey.pem&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Per site HTTPS configuration ====&lt;br /&gt;
&lt;br /&gt;
Add the following below the previous HTTP configuration:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Redirect HTTP to HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Shared configuration ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/redirect_http.inc&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
location / {&lt;br /&gt;
        return 301 https://$host$request_uri;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update host configuration ====&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
    include       conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Complete host example with IPv6 support ===&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# alpinelinux.org&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  80;&lt;br /&gt;
    listen                  [::]:80;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    include                 conf.d/acme.inc;&lt;br /&gt;
    include                 conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    listen                  [::]:443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
[[Category:Networking]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
	<entry>
		<id>https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14159</id>
		<title>Nginx as reverse proxy with acme (letsencrypt)</title>
		<link rel="alternate" type="text/html" href="https://wiki.alpinelinux.org/w/index.php?title=Nginx_as_reverse_proxy_with_acme_(letsencrypt)&amp;diff=14159"/>
		<updated>2017-12-01T16:34:45Z</updated>

		<summary type="html">&lt;p&gt;Flaxe: /* Update host configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Introduction ==&lt;br /&gt;
&lt;br /&gt;
This setup will allow you to have multiple servers/containers be accessible via a single IP address with the added benefit of centralized generation of letsencrypt certificates and secure https (according to ssllabs ssltest). Be aware you first need to setup regular HTTP server to be able to generate your HTTPS certificates and keys. After you have generated them you can add your HTTPS host based configuration.&lt;br /&gt;
&lt;br /&gt;
== Installation ==&lt;br /&gt;
&lt;br /&gt;
For this howto we need two tools, NGINX and acme-client.&lt;br /&gt;
&lt;br /&gt;
{{Cmd|apk add nginx acme-client}}&lt;br /&gt;
&lt;br /&gt;
== Setup ==&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTP ===&lt;br /&gt;
&lt;br /&gt;
==== Global configuration ====&lt;br /&gt;
&lt;br /&gt;
First step is to refactor our global nginx.conf. Its target at a low traffic http server, to increase performance make changes at top level.&lt;br /&gt;
&lt;br /&gt;
The security settings are taken from https://cipherli.st . Please also read https://hstspreload.org for details about HSTS.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# ngnix configuration file&lt;br /&gt;
&lt;br /&gt;
user  nginx;&lt;br /&gt;
&lt;br /&gt;
worker_processes  1; # use &amp;quot;auto&amp;quot; to use all available cores (high performance)&lt;br /&gt;
&lt;br /&gt;
events {&lt;br /&gt;
    worker_connections  1024; # increase if you need more connections&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
http {&lt;br /&gt;
    # server_names_hash_bucket_size controls the maximum length&lt;br /&gt;
    # of a virtual host entry (ie the length of the domain name).&lt;br /&gt;
    server_names_hash_bucket_size   64;&lt;br /&gt;
    server_tokens                   off; # hide who we are&lt;br /&gt;
    sendfile                        off; # can cause issues&lt;br /&gt;
&lt;br /&gt;
    # secure nginx according to https://cipherli.st/&lt;br /&gt;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;&lt;br /&gt;
    ssl_prefer_server_ciphers on;&lt;br /&gt;
    ssl_ciphers &amp;quot;EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH&amp;quot;;&lt;br /&gt;
    ssl_ecdh_curve secp384r1; # Requires nginx &amp;gt;= 1.1.0&lt;br /&gt;
    ssl_session_cache shared:SSL:10m;&lt;br /&gt;
    ssl_session_tickets off; # Requires nginx &amp;gt;= 1.5.9&lt;br /&gt;
    ssl_stapling on; # Requires nginx &amp;gt;= 1.3.7&lt;br /&gt;
    ssl_stapling_verify on; # Requires nginx =&amp;gt; 1.3.7&lt;br /&gt;
    resolver 8.8.8.8 8.8.4.4 valid=300s;&lt;br /&gt;
    resolver_timeout 5s;&lt;br /&gt;
    add_header Strict-Transport-Security &amp;quot;max-age=63072000&amp;quot;; # https://hstspreload.org&lt;br /&gt;
    add_header X-Frame-Options DENY;&lt;br /&gt;
    add_header X-Content-Type-Options nosniff;&lt;br /&gt;
&lt;br /&gt;
    ssl_dhparam dhparam.pem;&lt;br /&gt;
&lt;br /&gt;
    # nginx will find this file in the config directory set at nginx build time&lt;br /&gt;
    include mime.types;&lt;br /&gt;
&lt;br /&gt;
    #fallback in case we can&#039;t determine a type&lt;br /&gt;
    default_type application/octet-stream;&lt;br /&gt;
&lt;br /&gt;
    # buffering causes issues&lt;br /&gt;
    proxy_buffering off;&lt;br /&gt;
&lt;br /&gt;
    # include hosts&lt;br /&gt;
    include conf.d/*.conf;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Diffie–Hellman Parameters ====&lt;br /&gt;
&lt;br /&gt;
In the above configuration ssl_dhparam is used so we need to generate a global dhparam file. We want to use a 4096 key size but this can take a very long time. Because of this we are adding an extra option (dsaparam) to generate our dhparam file (see: https://wiki.openssl.org/index.php/Manual:Dhparam(1)#OPTIONS)&lt;br /&gt;
&lt;br /&gt;
{{Cmd|openssl dhparam -dsaparam -out /etc/nginx/dhparam.pem 4096}}&lt;br /&gt;
&lt;br /&gt;
At this point you should be able to (re)start your nginx server but it will not use any of the security features (yet).&lt;br /&gt;
&lt;br /&gt;
==== Per site configuration files (conf.d) ====&lt;br /&gt;
&lt;br /&gt;
Since Alpine v3.5 we ship NGINX with an default.conf within the /etc/nginx/conf.d directory.&lt;br /&gt;
To add support for another website you can add files with the .conf extension to this directory.&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Common configuration includes ====&lt;br /&gt;
&lt;br /&gt;
If you need to setup multiple proxy setups you can include duplicated data like shown below.&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/proxy_set_header.inc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
proxy_set_header    X-Forwarded-By       $server_addr:$server_port;&lt;br /&gt;
proxy_set_header    X-Forwarded-For      $remote_addr;&lt;br /&gt;
proxy_set_header    X-Forwarded-Proto    $scheme;&lt;br /&gt;
proxy_set_header    Host                 $host;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== acme-client ===&lt;br /&gt;
&lt;br /&gt;
To allow NGINX to support https we need to add certificates and support for ACME (Automatic Certificate Management Environment) responses.&lt;br /&gt;
&lt;br /&gt;
==== ACME responses ====&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/acme.inc:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
location /.well-known/acme-challenge {&lt;br /&gt;
    alias /var/www/acme;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
And add this to your proxy configuration&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include			conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass		http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Automatic generate certificates ====&lt;br /&gt;
&lt;br /&gt;
Create the following file and make it executable&lt;br /&gt;
 /etc/periodic/weekly/acme-client&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
#!/bin/sh&lt;br /&gt;
&lt;br /&gt;
hosts=&amp;quot;alpinelinux.org&amp;quot;&lt;br /&gt;
&lt;br /&gt;
for host in $hosts; do&lt;br /&gt;
        acme-client -a https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf -Nnmv $host &amp;amp;&amp;amp; renew=1&lt;br /&gt;
done&lt;br /&gt;
&lt;br /&gt;
[ &amp;quot;$renew&amp;quot; = 1 ] &amp;amp;&amp;amp; rc-service nginx reload&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This script will run weekly to verify if one of your certificates is outdated and renew them when needed.&lt;br /&gt;
&lt;br /&gt;
==== Initial generation of keys and certificates ====&lt;br /&gt;
&lt;br /&gt;
To create your initial certificates and keys you have to run this manually the first time.&lt;br /&gt;
&lt;br /&gt;
 {{Cmd|/etc/periodic/weekly/acme-client}}&lt;br /&gt;
&lt;br /&gt;
Watch the output and see if all goes well. When its finished you should have files in:&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/alpinelinux.nl/fullchain.pem&lt;br /&gt;
&lt;br /&gt;
 /etc/ssl/acme/private/alpinelinux.org/privkey.pem&lt;br /&gt;
&lt;br /&gt;
=== NGINX HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Per site HTTPS configuration ====&lt;br /&gt;
&lt;br /&gt;
Add the following below the previous HTTP configuration:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Redirect HTTP to HTTPS ===&lt;br /&gt;
&lt;br /&gt;
==== Shared configuration ====&lt;br /&gt;
&lt;br /&gt;
Create the following file:&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/redirect_http.inc&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
location / {&lt;br /&gt;
        return 301 https://$host$request_uri;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==== Update host configuration ====&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
server {&lt;br /&gt;
    listen        80;&lt;br /&gt;
    server_name   alpinelinux.org;&lt;br /&gt;
    include       conf.d/acme.inc;&lt;br /&gt;
    include       conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Complete host example with IPv6 support ===&lt;br /&gt;
&lt;br /&gt;
 /etc/nginx/conf.d/alpinelinux.org.conf&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# alpinelinux.org&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  80;&lt;br /&gt;
    listen                  [::]:80;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    include                 conf.d/acme.inc;&lt;br /&gt;
    include                 conf.d/redirect_http.inc;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
server {&lt;br /&gt;
    listen                  443 ssl;&lt;br /&gt;
    listen                  [::]:443 ssl;&lt;br /&gt;
    server_name             alpinelinux.org;&lt;br /&gt;
    ssl                     on;&lt;br /&gt;
    ssl_certificate         /etc/ssl/acme/alpinelinux.org/fullchain.pem;&lt;br /&gt;
    ssl_certificate_key     /etc/ssl/acme/private/alpinelinux.org/privkey.pem;&lt;br /&gt;
&lt;br /&gt;
    location / {&lt;br /&gt;
        include     conf.d/proxy_set_header.inc;&lt;br /&gt;
        proxy_pass  http://downstream_http_server_host;&lt;br /&gt;
    }&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Category:Authentication]]&lt;br /&gt;
[[Category:Networking]]&lt;/div&gt;</summary>
		<author><name>Flaxe</name></author>
	</entry>
</feed>