Show More
@@ -1,136 +1,143 b'' | |||
|
1 | 1 | Nginx Configuration Example |
|
2 | 2 | --------------------------- |
|
3 | 3 | |
|
4 | 4 | Use the following example to configure Nginx as a your web server. |
|
5 | 5 | |
|
6 | 6 | |
|
7 | 7 | .. code-block:: nginx |
|
8 | 8 | |
|
9 | 9 | ## rate limiter for certain pages to prevent brute force attacks |
|
10 | 10 | limit_req_zone $binary_remote_addr zone=dl_limit:10m rate=1r/s; |
|
11 | 11 | |
|
12 | 12 | ## custom log format |
|
13 | 13 | log_format log_custom '$remote_addr - $remote_user [$time_local] ' |
|
14 | 14 | '"$request" $status $body_bytes_sent ' |
|
15 | 15 | '"$http_referer" "$http_user_agent" ' |
|
16 | 16 | '$request_time $upstream_response_time $pipe'; |
|
17 | 17 | |
|
18 | 18 | ## define upstream (local RhodeCode instance) to connect to |
|
19 | 19 | upstream rc { |
|
20 | 20 | # Url to running RhodeCode instance. |
|
21 | 21 | # This is shown as `- URL:` in output from rccontrol status. |
|
22 | 22 | server 127.0.0.1:10002; |
|
23 | 23 | |
|
24 | 24 | # add more instances for load balancing |
|
25 | 25 | # server 127.0.0.1:10003; |
|
26 | 26 | # server 127.0.0.1:10004; |
|
27 | 27 | } |
|
28 | 28 | |
|
29 | 29 | ## HTTP to HTTPS rewrite |
|
30 | 30 | server { |
|
31 | 31 | listen 80; |
|
32 | 32 | server_name rhodecode.myserver.com; |
|
33 | 33 | |
|
34 | 34 | if ($http_host = rhodecode.myserver.com) { |
|
35 | 35 | rewrite (.*) https://rhodecode.myserver.com$1 permanent; |
|
36 | 36 | } |
|
37 | 37 | } |
|
38 | 38 | |
|
39 | 39 | ## Optional gist alias server, for serving nicer GIST urls. |
|
40 | 40 | server { |
|
41 | 41 | listen 443; |
|
42 | 42 | server_name gist.myserver.com; |
|
43 | 43 | access_log /var/log/nginx/gist.access.log log_custom; |
|
44 | 44 | error_log /var/log/nginx/gist.error.log; |
|
45 | 45 | |
|
46 | 46 | ssl on; |
|
47 | 47 | ssl_certificate gist.rhodecode.myserver.com.crt; |
|
48 | 48 | ssl_certificate_key gist.rhodecode.myserver.com.key; |
|
49 | 49 | |
|
50 | 50 | ssl_session_timeout 5m; |
|
51 | 51 | |
|
52 | 52 | ssl_protocols TLSv1 TLSv1.1 TLSv1.2; |
|
53 | 53 | ssl_prefer_server_ciphers on; |
|
54 | 54 | ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA'; |
|
55 | 55 | |
|
56 | 56 | # strict http prevents from https -> http downgrade |
|
57 | 57 | add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;"; |
|
58 | 58 | |
|
59 | 59 | # Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits |
|
60 | 60 | #ssl_dhparam /etc/nginx/ssl/dhparam.pem; |
|
61 | 61 | |
|
62 | 62 | rewrite ^/(.+)$ https://rhodecode.myserver.com/_admin/gists/$1; |
|
63 | 63 | rewrite (.*) https://rhodecode.myserver.com/_admin/gists; |
|
64 | 64 | } |
|
65 | 65 | |
|
66 | 66 | |
|
67 | 67 | ## MAIN SSL enabled server |
|
68 | 68 | server { |
|
69 | 69 | listen 443 ssl; |
|
70 | 70 | server_name rhodecode.myserver.com; |
|
71 | 71 | |
|
72 | 72 | access_log /var/log/nginx/rhodecode.access.log log_custom; |
|
73 | 73 | error_log /var/log/nginx/rhodecode.error.log; |
|
74 | 74 | |
|
75 | 75 | ssl on; |
|
76 | 76 | ssl_certificate rhodecode.myserver.com.crt; |
|
77 | 77 | ssl_certificate_key rhodecode.myserver.com.key; |
|
78 | 78 | |
|
79 | 79 | ssl_session_timeout 5m; |
|
80 | 80 | |
|
81 | 81 | ssl_protocols TLSv1 TLSv1.1 TLSv1.2; |
|
82 | 82 | ssl_prefer_server_ciphers on; |
|
83 | 83 | ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA'; |
|
84 | 84 | |
|
85 | 85 | # Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits |
|
86 | 86 | #ssl_dhparam /etc/nginx/ssl/dhparam.pem; |
|
87 | 87 | |
|
88 | 88 | include /etc/nginx/proxy.conf; |
|
89 | 89 | |
|
90 | 90 | ## serve static files by Nginx, recommended for performance |
|
91 | 91 | # location /_static/rhodecode { |
|
92 | # gzip on; | |
|
93 | # gzip_min_length 500; | |
|
94 | # gzip_proxied any; | |
|
95 | # gzip_comp_level 4; | |
|
96 | # gzip_types text/css text/javascript text/xml text/plain text/x-component application/javascript application/json application/xml application/rss+xml font/truetype font/opentype application/vnd.ms-fontobject image/svg+xml; | |
|
97 | # gzip_vary on; | |
|
98 | # gzip_disable "msie6"; | |
|
92 | 99 | # alias /path/to/.rccontrol/enterprise-1/static; |
|
93 | 100 | # } |
|
94 | 101 | |
|
95 | 102 | ## channelstream websocket handling |
|
96 | 103 | location /_channelstream { |
|
97 | 104 | rewrite /_channelstream/(.*) /$1 break; |
|
98 | 105 | |
|
99 | 106 | proxy_pass http://127.0.0.1:9800; |
|
100 | 107 | |
|
101 | 108 | proxy_connect_timeout 10; |
|
102 | 109 | proxy_send_timeout 10m; |
|
103 | 110 | proxy_read_timeout 10m; |
|
104 | 111 | tcp_nodelay off; |
|
105 | 112 | proxy_set_header Host $host; |
|
106 | 113 | proxy_set_header X-Real-IP $remote_addr; |
|
107 | 114 | proxy_set_header X-Url-Scheme $scheme; |
|
108 | 115 | proxy_set_header X-Forwarded-Proto $scheme; |
|
109 | 116 | proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
|
110 | 117 | gzip off; |
|
111 | 118 | proxy_http_version 1.1; |
|
112 | 119 | proxy_set_header Upgrade $http_upgrade; |
|
113 | 120 | proxy_set_header Connection "upgrade"; |
|
114 | 121 | } |
|
115 | 122 | |
|
116 | 123 | location /_admin/login { |
|
117 | 124 | ## rate limit this endpoint |
|
118 | 125 | limit_req zone=dl_limit burst=10 nodelay; |
|
119 | 126 | try_files $uri @rhode; |
|
120 | 127 | } |
|
121 | 128 | |
|
122 | 129 | location / { |
|
123 | 130 | try_files $uri @rhode; |
|
124 | 131 | } |
|
125 | 132 | |
|
126 | 133 | location @rhode { |
|
127 | 134 | proxy_pass http://rc; |
|
128 | 135 | } |
|
129 | 136 | |
|
130 | 137 | ## custom 502 error page. Will be displayed while RhodeCode server |
|
131 | 138 | ## is turned off |
|
132 | 139 | error_page 502 /502.html; |
|
133 | 140 | location = /502.html { |
|
134 | 141 | root /path/to/.rccontrol/enterprise-1/static; |
|
135 | 142 | } |
|
136 | 143 | } No newline at end of file |
General Comments 0
You need to be logged in to leave comments.
Login now