S
S
Semyon Dubina2012-05-04 07:43:34
PHP
Semyon Dubina, 2012-05-04 07:43:34

What are the limitations for nginx+fastcgi redirect requests?

Available: a pair of servers (id=1-primary, on VDS; id=2-backup (home)). They are synchronized by rsync, mysql in master-master mode, those are a full-fledged cluster in two nodes with a delay of about 100 ms. I still can’t adjust nginx to work in this mode, now I just use a group of servers (upstream) for fastcgi, but this way satika is loaded only from server id=1 and the browser doesn’t like it (when contacting the backup server, di=2 ignores loading statics) . Both servers have the same databases, all links are identical... What could be the problem? Here is the "stump" of the config:

fastcgi_cache_path ****<br/>
<br/>
upstream group_srv {<br/>
 server 127.0.0.1:1234;<br/>
 server 8.8.8.8:4321 backup;<br/>
}<br/>
server {<br/>
 listen 80;<br/>
 server_name google.ru <a href="http://www.google.ru">www.google.ru</a> server.google.ru;<br/>
--//<br/>
//--<br/>
 location ~* ^/statics/.+\.(js|css|png|jpg|gif|jpeg|ico)$ {<br/>
 root /var/www/google;<br/>
 rewrite ^/.*(/statics/.*\.(js|css|png|jpg|gif|jpeg|ico))$ last;<br/>
 access_log off;<br/>
 expires 7d;<br/>
 }<br/>
<br/>
location @default {<br/>
 fastcgi_pass group_srv;<br/>
 fastcgi_param SCRIPT_FILENAME $document_root/index.php;<br/>
 include /etc/nginx/fastcgi_params;<br/>
 fastcgi_param SCRIPT_NAME /index.php;<br/>
 fastcgi_index index.php;<br/>
 if ($do_not_cache != &quot;1&quot;) {<br/>
 add_header Vary Cookie;<br/>
 }<br/>
 }<br/>
<br/>
location / {<br/>
 gzip_static on;<br/>
 try_files $uri $uri/ @default;<br/>
 if (-f $request_filename) {<br/>
 expires max;<br/>
 break;<br/>
 }<br/>
 set $cache_file '';<br/>
 set $cache_uri $request_uri;<br/>
 if ($request_method = POST) {<br/>
 set $cache_uri '';<br/>
 }<br/>
 if ($query_string) {<br/>
 set $cache_uri '';<br/>
 }<br/>
 if ($http_cookie ~* &quot;my_coockie|any_coockie_&quot; ) {<br/>
 set $cache_uri '';<br/>
 }<br/>
 if ($cache_uri ~ ^(.+)$) {<br/>
 set $cache_file /var/www/google/plugins/cache$http_host/$1index.html;<br/>
 }<br/>
 if (-f $document_root$cache_file) {<br/>
 rewrite ^(.*)$ $cache_file break;<br/>
 }<br/>
 if (!-e $request_filename) {<br/>
 rewrite . /index.php last;<br/>
 }<br/>
 }<br/>
}<br/>

Both locally and on a remote server, the request is accepted by php-fpm.
Here I am racking my brains about what are the restrictions for redirects / links in browsers, because the address for statics is correct, but the browser still ignores downloading from it. Dedicate, please, what I have not yet been able to comprehend, what to look at, what to change?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
H
hg_04, 2012-05-04
@sam002

if both servers are external then it is better to proxy the results, so you will have more control.
> but so satika is loaded only from the server id=1 of
course you also have it written that you should always take it from the root /var/www/google folder;
>rewrite ^/.*(/statics/.*\.(js|css|png|jpg|gif|jpeg|ico))$ last;
strange rule, what did you want to achieve with it?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question