]> git.mxchange.org Git - friendica.git/blob - mods/sample-nginx-reverse-proxy.config
Fix missing values in sample files
[friendica.git] / mods / sample-nginx-reverse-proxy.config
1 #
2 # Example of NGINX as reverse-proxy terminating an HTTPS connection.
3 #
4 # This is not a complete NGINX config.
5 #
6 # Please refer to NGINX docs
7 #
8
9 # Note provided by Gabe R.: if you are using nginx as proxy server for Apache2
10 # make sure your nginx config DOES NOT contain the following
11 # -----
12 # location ~ /.well-known {
13 #  allow all;
14 #  }
15 # -----
16 ...
17
18
19 ##
20 # by https://syshero.org/2018-04-13-nginx-unique-request-identifier/
21 # if X-Request-ID is set, NGINX will forward the same value to the next upstream
22 # if the header is not set, NGINX will generate a random request identifier and add it to the request.
23 #
24 # To guarantee backward compatibility, map to format the $request_id variable to a format that matches any old setups.
25 ##
26
27 map $request_id $formatted_id {
28   "~*(?<p1>[0-9a-f]{8})(?<p2>[0-9a-f]{4})(?<p3>[0-9a-f]{4})(?<p4>[0-9a-f]{4})(?<p5>.*)$" "${p1}-${p2}-${p3}-${p4}-${p5}";
29 }
30
31 map $http_x_request_id $uuid {
32   default   "${request_id}";
33   ~*        "${http_x_request_id}";
34 }
35
36
37 server {
38
39         ...
40
41         # assuming Friendica runs on port 8080
42         location / {
43                 if ( $scheme != https ) {
44                         # Force Redirect to HTTPS
45                         return 302 https://$host$uri;
46                 }
47                 proxy_pass http://localhost:8080;
48                 proxy_redirect off;
49                 proxy_set_header Host $host;
50                 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
51                 proxy_set_header Forwarded "for=$proxy_add_x_forwarded_for; proto=$scheme";
52                 proxy_set_header X-Request-ID $uuid;
53         }
54
55         ...
56
57 }