Nginx and cscart

hi,
i asked this question in other topics but did not get the complete
solution yet.
many problems solved but one final of pice of puzzle is still unsolved;

we want to use nginx in front of three cs cart web servers;
one server is for images(192.168.1.3) and two others(192.168.1.1,
192.168.1.2) for web site files of cscart…
this is my complete config so far :

user nginx nginx;
worker_processes 4;
error_log var/log/error.log;
pid var/run/nginx.pid;
events {
worker_connections 4098;
}
http {
keepalive_timeout 65;
include mime.types;

default_type application/octet-stream;
sendfile on;
gzip on;
gzip_min_length 1000;
gzip_proxied expired no-cache no-store private auth;
gzip_types text/plain application/xml text/css;
gzip_disable “MSIE [1-6].”;

upstream mysites_hash {
ip_hash;
server 192.168.1.1;
server 192.168.1.2 down;
}
upstream myimages {
server 192.168.1.3;
}

server {
listen 80;
server_name www.mydomain.com;
location / {
deny all;
}
location /csupdate/images {
proxy_pass http://myimages/images;
}
location /csupdate {
proxy_pass http://mysites_hash/csupdate;
proxy_set_header Host 192.168.1.1;
proxy_redirect http://192.168.1.1/csupdate
http://www.mydomain.com/csupdate;

  }
  location /nginx_status {
      stub_status on;
      access_log   off;
      allow my_own_ip-address;
      deny all;
  }

}

}

some notes :

  1. cs cart has a setion in its config that i have to add server address
    and also some path
    for example i have to define 192.168.1.1 and also define “csupdate”
    (csupdate is a virtual address of my site under 192.168.1.1 or
    192.168.1.2); then cscart redirect users to this address so it does some
    redirection so i need to use proxy_redirect ang proxy_set_header as
    above;

  2. the above config is working fine because i set the 2th server down
    (192.168.1.2) and use 1th server address manually
    in my /csupdate location but i can not enable my 2th server because
    i don’t know how to config my csupdate location

is there any thing i can do for this problem ???

thank you in advance;

Posted at Nginx Forum:

Think of nginx as a transparent proxy/frontend - so instead of giving
proxy_set_header Host 192.168.1.1; you should set the real hostname of
the
site proxy_set_header Host yoursite.com; (you can also use $host
variable if
there are multiple/dynamic domains).

upstream mysites_hash {
ip_hash;
server 192.168.1.1;
server 192.168.1.2;
}

location /csupdate {
proxy_pass http://mysites_hash/csupdate;
proxy_set_header Host www.mydomain.com;
}

That way the backends/application should use full domain (the one you
pass
in the header) in the redirects which will go through your nginx
frontend
without the need of extra proxy_redirect directives.

rr

Hi,
thank you for reply…

first i remove proxy_rediretct and add www.mydomain.com as you told;
in this case my address bar change to 192.168.1.1 and as i saw the users
directly connect to 192.168.1.1
but i don’t want this; i need address bar always be as www.mydomain.com

then i add my proxy_redirect code and the browser fell into endless
loop;

thank you again;

Posted at Nginx Forum:

the only solution that worked is the above config but in this case i can
not use 192.168.1.2 to load balancing my requests…

Posted at Nginx Forum:

Really no soloution to this problem ??

i can give more info if needed

Posted at Nginx Forum:

god damin it; i forgot to change redirect domain in my backend;
Reinis! it seems your soloution works…

i 'm so sorry…
i will give more info if there is any problem yet…

Posted at Nginx Forum:

hi again;
if any moe information is need plz tell me;
I think this problem must have a soloution in nginx;

Posted at Nginx Forum: