# Nginx - Joomla

**URL:** <https://www.ruby-forum.com/t/nginx-joomla/219225>\
**Category:** NGINX\
**Created:** [April 24, 2012, 4:16pm UTC](https://www.ruby-forum.com/t/nginx-joomla/219225 "2012-04-24T16:16:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gurdipe\_D](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/b77776/32.png) [@Gurdipe\_D](https://www.ruby-forum.com/u/Gurdipe_D)\
**Post date:** [April 24, 2012, 4:16pm UTC](https://www.ruby-forum.com/t/nginx-joomla/219225/1 "2012-04-24T16:16:49Z")

</div>

I installed Nginx for Windows. Added the php to run joomla.  
I’m problems with CGI.  
I often have the error “502 bad gateway” after a while.  
how do I fix this?  
What is the best configuration of nginx to run joomla?

Server:  
Windows 2008  
Dual-Core 2.0GHZ.  
Ram: 2 GB

Posted at Nginx Forum:

> **[Nginx - Joomla](https://forum.nginx.org/read.php?2,225707,225707#msg-225707)**
>
> I installed Nginx for Windows. Added the php to run joomla. I'm problems with CGI. I often have the error "502 bad gateway" after a while. how do I fix this? What is the best configuration of nginx to run joomla? Server: Windows 2008

---

<div class="post-metadata">

**Author:** ![borgita](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d9b06d/32.png) [@borgita](https://www.ruby-forum.com/u/borgita)\
**Post date:** [April 24, 2012, 5:09pm UTC](https://www.ruby-forum.com/t/nginx-joomla/219225/2 "2012-04-24T17:09:38Z")

</div>

Hello,

Can you please paste your vhost or nginx.conf file?

Regards,

Justin D.  
(sent on my Droid)

---

<div class="post-metadata">

**Author:** ![borgita](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d9b06d/32.png) [@borgita](https://www.ruby-forum.com/u/borgita)\
**Post date:** [April 24, 2012, 6:03pm UTC](https://www.ruby-forum.com/t/nginx-joomla/219225/3 "2012-04-24T18:03:41Z")

</div>

This is what works for me on Debian/Ubuntu (with PHP-FPM):

[http://www.howtoforge.com/running-joomla-1.7-on-nginx-lemp-on-debian-squeeze-ubuntu-11.10](http://www.howtoforge.com/running-joomla-1.7-on-nginx-lemp-on-debian-squeeze-ubuntu-11.10)

I haven’t tested this on Windows, but the configuration should be  
similar.

----- Original Message -----  
From: “borgita” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Tuesday, April 24, 2012 4:16 PM  
Subject: Nginx - Joomla

---

<div class="post-metadata">

**Author:** ![borgita](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/d9b06d/32.png) [@borgita](https://www.ruby-forum.com/u/borgita)\
**Post date:** [April 24, 2012, 6:15pm UTC](https://www.ruby-forum.com/t/nginx-joomla/219225/4 "2012-04-24T18:15:31Z")

</div>

I’ve tried lots of things in the file nginx.conf. The server is now more  
stable. In php settings that are required to include?

nginx.conf

#user nobody;  
master\_process on;  
worker\_processes 2;

events {  
worker\_connections 1024;  
}

http {  
sendfile on;  
client\_max\_body\_size 10M;  
tcp\_nopush off;  
tcp\_nodelay on;  
server\_tokens off;  
include /nginx/conf/mime.types;  
default\_type application/octet-stream;  
index index.php index.htm index.html redirect.php;  
charset utf-8;  
keepalive\_timeout 65;

#Gzip  
gzip on;  
gzip\_vary on;  
gzip\_proxied any;  
gzip\_comp\_level 6;  
gzip\_buffers 16 8k;  
gzip\_http\_version 1.1;  
gzip\_disable “MSIE [1-6].(?!.\*SV1)”;  
gzip\_types text/plain text/css application/json  
application/x-javascript text/xml  
application/xml application/xml+rss  
text/javascript;

#FastCGI  
fastcgi\_buffers 8 16k;  
fastcgi\_buffer\_size 32k;

upstream fastcgi\_backend {  
server 127.0.0.1:9000 weight=2;  
server 127.0.0.1:9001 weight=3;  
server 127.0.0.1:9002 weight=4;  
}

limit\_req\_zone $binary\_remote\_addr zone=one:10m rate=1r/s;

```
server {
    listen 80;
    server_name xxx.pt www.xxx.pt;
server_name_in_redirect off;
    large_client_header_buffers 4 8k; # prevent some 400 errors;

error_log /nginx/xxx.log;

    root html;

location / {
    root html;
  try_files $uri $uri/ /index.php?p=$uri&$args;
  expires 30d;
  error_page 404 = @joomla;
  error_page 500 502 503 504 = @joomla;
  log_not_found off;
}

location @joomla {
  rewrite ^(.+)$ /index.php?p=$1 last;
}

location ~ \.php$ {
     root html;
   try_files $uri =404;
   fastcgi_split_path_info ^(.+\.php)(/.+)$;
         fastcgi_index index.php;
         fastcgi_param SCRIPT_FILENAME

```

c:/nginx/html/$fastcgi\_script\_name;  
fastcgi\_keep\_conn on;  
fastcgi\_intercept\_errors on;  
if ($uri !~ “^/images/”) {  
fastcgi\_pass fastcgi\_backend;  
}  
include fastcgi\_params;

```
     }

if ( $args ~ "mosConfig_[a-zA-Z_]{1,21}(=|\%3d)" ) {
  set $args "";
  rewrite ^.*$ http://$host/index.php last;
  return 403;
}

if ( $args ~ "base64_encode.*\(.*\)" ) {
  set $args "";
  rewrite ^.*$ http://$host/index.php last;
  return 403;
}

if ( $args ~ "(\<|%3C).*script.*(\>|%3E)" ) {
  set $args "";
  rewrite ^.*$ http://$host/index.php last;
  return 403;
}

if ( $args ~ "GLOBALS(=|\[|\%[0-9A-Z]{0,2})" ) {
  set $args "";
  rewrite ^.*$ http://$host/index.php last;
  return 403;
}

if ( $args ~ "_REQUEST(=|\[|\%[0-9A-Z]{0,2})" ) {
  set $args "";
  rewrite ^.*$ http://$host/index.php last;
  return 403;
}

location ~* \.(ico|pdf|flv)$ {
  access_log off;
  expires 1y;
}
location = /robots.txt {
  allow all;
  log_not_found off;
  access_log off;
}

location ~*

```

.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$  
{  
access\_log off;  
expires 14d;  
}  
# fim  
location ~ .php$ {  
deny all;  
}  
}

}

Posted at Nginx Forum:

> **[Re: Nginx - Joomla](https://forum.nginx.org/read.php?2,225707,225715#msg-225715)**
>
> I installed Nginx for Windows. Added the php to run joomla. I'm problems with CGI. I often have the error "502 bad gateway" after a while. how do I fix this? What is the best configuration of nginx to run joomla? Server: Windows 2008
