# Nginx and cscart

**URL:** <https://www.ruby-forum.com/t/nginx-and-cscart/208718>\
**Category:** NGINX\
**Created:** [June 25, 2011, 9:29am UTC](https://www.ruby-forum.com/t/nginx-and-cscart/208718 "2011-06-25T09:29:58Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![dubstep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/cdc98d/32.png) [@dubstep](https://www.ruby-forum.com/u/dubstep)\
**Post date:** [June 25, 2011, 9:29am UTC](https://www.ruby-forum.com/t/nginx-and-cscart/208718/1 "2011-06-25T09:29:58Z")

</div>

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](http://www.mydomain.com);  
location / {  
deny all;  
}  
location /csupdate/images {  
proxy\_pass [http://myimages/images](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://192.168.1.1/csupdate)  
[http://www.mydomain.com/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:

> **[nginx and cscart](https://forum.nginx.org/read.php?2,209882,209882#msg-209882)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![torajx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/22d042/32.png) [@torajx](https://www.ruby-forum.com/u/torajx)\
**Post date:** [June 27, 2011, 11:09am UTC](https://www.ruby-forum.com/t/nginx-and-cscart/208718/2 "2011-06-27T11:09:42Z")

</div>

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](http://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](http://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

---

<div class="post-metadata">

**Author:** ![torajx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/22d042/32.png) [@torajx](https://www.ruby-forum.com/u/torajx)\
**Post date:** [June 27, 2011, 11:55am UTC](https://www.ruby-forum.com/t/nginx-and-cscart/208718/3 "2011-06-27T11:55:25Z")

</div>

Hi,  
thank you for reply…

first i remove proxy\_rediretct and add [www.mydomain.com](http://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](http://www.mydomain.com)

then i add my proxy\_redirect code and the browser fell into endless  
loop;

thank you again;

Posted at Nginx Forum:

> **[Re: nginx and cscart](https://forum.nginx.org/read.php?2,209882,210381#msg-210381)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![torajx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/22d042/32.png) [@torajx](https://www.ruby-forum.com/u/torajx)\
**Post date:** [June 27, 2011, 11:57am UTC](https://www.ruby-forum.com/t/nginx-and-cscart/208718/4 "2011-06-27T11:57:16Z")

</div>

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:

> **[Re: nginx and cscart](https://forum.nginx.org/read.php?2,209882,210382#msg-210382)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![torajx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/22d042/32.png) [@torajx](https://www.ruby-forum.com/u/torajx)\
**Post date:** [June 27, 2011, 7:04am UTC](https://www.ruby-forum.com/t/nginx-and-cscart/208718/5 "2011-06-27T07:04:40Z")

</div>

Really no soloution to this problem ??

i can give more info if needed

Posted at Nginx Forum:

> **[Re: nginx and cscart](https://forum.nginx.org/read.php?2,209882,210333#msg-210333)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![torajx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/22d042/32.png) [@torajx](https://www.ruby-forum.com/u/torajx)\
**Post date:** [July 2, 2011, 8:41am UTC](https://www.ruby-forum.com/t/nginx-and-cscart/208718/6 "2011-07-02T08:41:55Z")

</div>

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:

> **[Re: nginx and cscart](https://forum.nginx.org/read.php?2,209882,211733#msg-211733)**
>
> 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...

---

<div class="post-metadata">

**Author:** ![torajx](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/t/22d042/32.png) [@torajx](https://www.ruby-forum.com/u/torajx)\
**Post date:** [July 2, 2011, 8:33am UTC](https://www.ruby-forum.com/t/nginx-and-cscart/208718/7 "2011-07-02T08:33:17Z")

</div>

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:

> **[Re: nginx and cscart](https://forum.nginx.org/read.php?2,209882,211730#msg-211730)**
>
> 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...
