##// END OF EJS Templates
docs: added example upload store cache with Nginx
marcink -
r3448:51bb9d9f default
parent child Browse files
Show More
@@ -1,161 +1,192 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=req_limit:10m rate=1r/s;
11 11
12 ## cache zone
13 proxy_cache_path /etc/nginx/nginx_cache levels=1:2 use_temp_path=off keys_zone=cache_zone:10m inactive=720h max_size=10g;
14
12 15 ## Custom log format
13 16 log_format log_custom '$remote_addr - $remote_user [$time_local] '
14 17 '"$request" $status $body_bytes_sent '
15 18 '"$http_referer" "$http_user_agent" '
16 19 '$request_time $upstream_response_time $pipe';
17 20
18 21 ## Define one or more upstreams (local RhodeCode instance) to connect to
19 22 upstream rc {
20 23 # Url to running RhodeCode instance.
21 24 # This is shown as `- URL: <host>` in output from rccontrol status.
22 25 server 127.0.0.1:10002;
23 26
24 27 # add more instances for load balancing
25 28 # server 127.0.0.1:10003;
26 29 # server 127.0.0.1:10004;
27 30 }
28 31
29 32 ## HTTP to HTTPS rewrite
30 33 server {
31 34 listen 80;
32 35 server_name rhodecode.myserver.com;
33 36
34 37 if ($http_host = rhodecode.myserver.com) {
35 38 rewrite (.*) https://rhodecode.myserver.com$1 permanent;
36 39 }
37 40 }
38 41
39 42 ## Optional gist alias server, for serving nicer GIST urls.
40 43 server {
41 44 listen 443;
42 45 server_name gist.myserver.com;
43 46 access_log /var/log/nginx/gist.access.log log_custom;
44 47 error_log /var/log/nginx/gist.error.log;
45 48
46 49 ssl on;
47 50 ssl_certificate gist.rhodecode.myserver.com.crt;
48 51 ssl_certificate_key gist.rhodecode.myserver.com.key;
49 52
50 53 ssl_session_timeout 5m;
51 54
52 55 ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
53 56 ssl_prefer_server_ciphers on;
54 57 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 58
56 59 ## Strict http prevents from https -> http downgrade
57 60 add_header Strict-Transport-Security "max-age=31536000; includeSubdomains;";
58 61
59 62 ## Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits
60 63 #ssl_dhparam /etc/nginx/ssl/dhparam.pem;
61 64
62 65 rewrite ^/(.+)$ https://rhodecode.myserver.com/_admin/gists/$1;
63 66 rewrite (.*) https://rhodecode.myserver.com/_admin/gists;
64 67 }
65 68
66 69
67 70 ## MAIN SSL enabled server
68 71 server {
69 72 listen 443 ssl http2;
70 73 server_name rhodecode.myserver.com;
71 74
72 75 access_log /var/log/nginx/rhodecode.access.log log_custom;
73 76 error_log /var/log/nginx/rhodecode.error.log;
74 77
75 78 ssl_certificate rhodecode.myserver.com.crt;
76 79 ssl_certificate_key rhodecode.myserver.com.key;
77 80
78 81 # enable session resumption to improve https performance
79 82 # http://vincent.bernat.im/en/blog/2011-ssl-session-reuse-rfc5077.html
80 83 ssl_session_cache shared:SSL:50m;
81 84 ssl_session_timeout 5m;
82 85
83 86 ## Diffie-Hellman parameter for DHE ciphersuites, recommended 2048 bits
84 87 #ssl_dhparam /etc/nginx/ssl/dhparam.pem;
85 88
86 89 # enables server-side protection from BEAST attacks
87 90 # http://blog.ivanristic.com/2013/09/is-beast-still-a-threat.html
88 91 ssl_prefer_server_ciphers on;
89 92
90 93 # disable SSLv3(enabled by default since nginx 0.8.19) since it's less secure then TLS http://en.wikipedia.org/wiki/Secure_Sockets_Layer#SSL_3.0
91 94 ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
92 95
93 96 # ciphers chosen for forward secrecy and compatibility
94 97 # http://blog.ivanristic.com/2013/08/configuring-apache-nginx-and-openssl-for-forward-secrecy.html
95 98 ssl_ciphers "ECDHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA:ECDHE-RSA-AES128-SHA:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA:DHE-RSA-AES128-SHA:ECDHE-RSA-DES-CBC3-SHA:EDH-RSA-DES-CBC3-SHA:AES256-GCM-SHA384:AES128-GCM-SHA256:AES256-SHA256:AES128-SHA256:AES256-SHA:AES128-SHA:DES-CBC3-SHA:HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4";
96 99
97 100 client_body_buffer_size 128k;
98 101 # maximum number and size of buffers for large headers to read from client request
99 102 large_client_header_buffers 16 256k;
100 103
101 104 ## uncomment to serve static files by Nginx, recommended for performance
102 105 # location /_static/rhodecode {
103 106 # gzip on;
104 107 # gzip_min_length 500;
105 108 # gzip_proxied any;
106 109 # gzip_comp_level 4;
107 110 # 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;
108 111 # gzip_vary on;
109 112 # gzip_disable "msie6";
110 113 # alias /path/to/.rccontrol/community-1/static;
111 114 # alias /path/to/.rccontrol/enterprise-1/static;
112 115 # }
113 116
114 117 ## channelstream location handler, if channelstream live chat and notifications
115 118 ## are enable this will proxy the requests to channelstream websocket server
116 119 location /_channelstream {
117 120 rewrite /_channelstream/(.*) /$1 break;
118 121 gzip off;
119 122 tcp_nodelay off;
120 123
121 124 proxy_connect_timeout 10;
122 125 proxy_send_timeout 10m;
123 126 proxy_read_timeout 10m;
124 127
125 128 proxy_set_header Host $host;
126 129 proxy_set_header X-Real-IP $remote_addr;
127 130 proxy_set_header X-Url-Scheme $scheme;
128 131 proxy_set_header X-Forwarded-Proto $scheme;
129 132 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
130 133
131 134 proxy_http_version 1.1;
132 135 proxy_set_header Upgrade $http_upgrade;
133 136 proxy_set_header Connection "upgrade";
134 137
135 138 proxy_pass http://127.0.0.1:9800;
136 139 }
137 140
138 141 ## rate limit this endpoint to prevent login page brute-force attacks
139 142 location /_admin/login {
140 143 limit_req zone=req_limit burst=10 nodelay;
141 144 try_files $uri @rhodecode_http;
142 145 }
143 146
147 ## Special Cache for file store, make sure you enable this intentionally as
148 ## it could bypass upload files permissions
149 # location /_file_store/download {
150 #
151 # proxy_cache cache_zone;
152 # # ignore Set-Cookie
153 # proxy_ignore_headers Set-Cookie;
154 # proxy_ignore_headers Cookie;
155 #
156 # proxy_cache_key $host$uri$is_args$args;
157 # proxy_cache_methods GET;
158 #
159 # proxy_cache_bypass $http_cache_control;
160 # proxy_cache_valid 200 302 720h;
161 #
162 # proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
163 #
164 # # returns cache status in headers
165 # add_header X-Proxy-Cache $upstream_cache_status;
166 # add_header Cache-Control "public";
167 #
168 # proxy_cache_lock on;
169 # proxy_cache_lock_age 5m;
170 #
171 # proxy_pass http://rc;
172 #
173 # }
174
144 175 location / {
145 176 try_files $uri @rhodecode_http;
146 177 }
147 178
148 179 location @rhodecode_http {
149 180 # example of proxy.conf can be found in our docs.
150 181 include /etc/nginx/proxy.conf;
151 182 proxy_pass http://rc;
152 183 }
153 184
154 185 ## Custom 502 error page.
155 186 ## Will be displayed while RhodeCode server is turned off
156 187 error_page 502 /502.html;
157 188 location = /502.html {
158 189 #root /path/to/.rccontrol/community-1/static;
159 190 root /path/to/.rccontrol/enterprise-1/static;
160 191 }
161 192 } No newline at end of file
General Comments 0
You need to be logged in to leave comments. Login now