# Nginx\_cross\_origin\_module on nginx-1.2.1

**URL:** <https://www.ruby-forum.com/t/nginx-cross-origin-module-on-nginx-1-2-1/222794>\
**Category:** NGINX\
**Created:** [September 11, 2012, 7:16am UTC](https://www.ruby-forum.com/t/nginx-cross-origin-module-on-nginx-1-2-1/222794 "2012-09-11T07:16:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/258eb7/32.png) [@aris](https://www.ruby-forum.com/u/aris)\
**Post date:** [September 11, 2012, 7:16am UTC](https://www.ruby-forum.com/t/nginx-cross-origin-module-on-nginx-1-2-1/222794/1 "2012-09-11T07:16:47Z")

</div>

Hi,

We are trying to implement cross origin resource sharing protocol on our  
system. I just want to try nginx\_cross\_origin\_module and see how it work  
instead of add\_header approach.

The issue is I can’t see the CORS headers on the response headers. Here  
is  
my config.

user nginx;  
worker\_processes 1;

error\_log /usr/local/nginx/logs/error.log info;  
pid /var/run/nginx.pid;

events {  
worker\_connections 1024;  
}

http {  
include /etc/nginx/mime.types;  
default\_type application/octet-stream;

```
log_format main '$remote_addr - $remote_user [$time_local] 

```

“$request”  
’  
'$status $body\_bytes\_sent “$http\_referer” ’  
‘“$http\_user\_agent” “$http\_x\_forwarded\_for”’;

```
access_log /var/log/nginx/access.log main;

sendfile on;

    cors on;
    cors_max_age 3600;
    cors_origin_list unbounded;
    cors_method_list GET HEAD PUT POST OPTIONS;
    cors_header_list unbounded;

```

server {  
listen 80;  
server\_name localhost;

```
        location / {
            root /usr/share/nginx/html;
            index index.html index.htm;
        }
    }

```

Response Headers  
Accept-Ranges bytes  
Content-Length 162  
Content-Type text/html  
Date Tue, 11 Sep 2012 05:04:44 GMT  
Last-Modified Tue, 11 Sep 2012 04:08:30 GMT  
Server nginx/1.2.1-5

Request Headers  
Accept text/html,application/xhtml+xml,application/xml;q=0.9,_/_;q=0.8  
Accept-Encoding gzip, deflate  
Accept-Language en-us,en;q=0.5  
Connection keep-alive  
Host x.x.x.x  
User-Agent Mozilla/5.0 (Windows NT 6.1; rv:15.0) Gecko/20100101  
Firefox/15.0

[root@abmx-test nginx]# nginx -V  
nginx version: nginx/1.2.1-5  
built by gcc 4.1.2 20080704 (Red Hat 4.1.2-48)  
TLS SNI support disabled  
configure arguments: --prefix=/etc/nginx/ --sbin-path=/usr/sbin/nginx  
–conf-path=/etc/nginx/nginx.conf  
–error-log-path=/var/log/nginx/error.log  
–http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx.pid  
–lock-path=/var/run/nginx.lock  
–http-client-body-temp-path=/var/cache/nginx/client\_temp  
–http-proxy-temp-path=/var/cache/nginx/proxy\_temp  
–http-fastcgi-temp-path=/var/cache/nginx/fastcgi\_temp  
–http-uwsgi-temp-path=/var/cache/nginx/uwsgi\_temp  
–http-scgi-temp-path=/var/cache/nginx/scgi\_temp --user=nginx  
–group=nginx  
–with-http\_ssl\_module --with-http\_realip\_module  
–with-http\_addition\_module  
–with-http\_sub\_module --with-http\_dav\_module --with-http\_flv\_module  
–with-http\_mp4\_module --with-http\_gzip\_static\_module  
–with-http\_random\_index\_module --with-http\_secure\_link\_module  
–with-http\_stub\_status\_module --with-mail\_ssl\_module --with-file-aio  
–with-debug --with-cc-opt=‘-O2 -g -m32 -march=i386 -mtune=generic  
-fasynchronous-unwind-tables’ --without-http\_uwsgi\_module  
–without-http\_scgi\_module --without-mail\_pop3\_module  
–without-mail\_imap\_module --without-mail\_smtp\_module  
–add-module=/usr/local/hirantha/rpmbuild/BUILD/nginx-1.2.1/contrib/yaoweibin-nginx\_upstream\_check\_module-2c5a2c8  
–add-module=/usr/local/hirantha/rpmbuild/BUILD/nginx-1.2.1/contrib/yaoweibin-nginx\_tcp\_proxy\_module-a40c99a  
–add-module=/usr/local/hirantha/rpmbuild/BUILD/nginx-1.2.1/contrib/simpl-ngx\_devel\_kit-24202b4  
–add-module=/usr/local/hirantha/rpmbuild/BUILD/nginx-1.2.1/contrib/agentzh-echo-nginx-module-080c0a1  
–add-module=/usr/local/hirantha/rpmbuild/BUILD/nginx-1.2.1/contrib/agentzh-set-misc-nginx-module-87d0ab2  
–add-module=/usr/local/hirantha/rpmbuild/BUILD/nginx-1.2.1/contrib/mikewest-nginx-static-etags-25bfaf9  
–add-module=/usr/local/hirantha/rpmbuild/BUILD/nginx-1.2.1/contrib/nginx-sticky-module-1.0  
–add-module=/usr/local/hirantha/rpmbuild/BUILD/nginx-1.2.1/contrib/agentzh-memc-nginx-module-8befc56  
–add-module=/usr/local/hirantha/rpmbuild/BUILD/nginx-1.2.1/contrib/agentzh-srcache-nginx-module-8df221e  
–add-module=/usr/local/hirantha/rpmbuild/BUILD/nginx-1.2.1/contrib/yaoweibin-nginx\_cross\_origin\_module-7319ab1

Do you need to build the module for the nginx-1.2.1 version or I’m  
missing  
something here…?

Thanks in advance

Posted at Nginx Forum:

> **[nginx\_cross\_origin\_module on nginx-1.2.1](https://forum.nginx.org/read.php?2,230641,230641#msg-230641)**
>
> Hi, We are trying to implement cross origin resource sharing protocol on our system. I just want to try nginx\_cross\_origin\_module and see how it work instead of add\_header approach. The issue is I can't see the CORS headers on the response headers....

---

<div class="post-metadata">

**Author:** ![n1xman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/13edae/32.png) [@n1xman](https://www.ruby-forum.com/u/n1xman)\
**Post date:** [September 11, 2012, 8:35am UTC](https://www.ruby-forum.com/t/nginx-cross-origin-module-on-nginx-1-2-1/222794/2 "2012-09-11T08:35:03Z")

</div>

HI,

Your request should contain an “Origin: [xxx.com](http://xxx.com)” head. If there is no  
such header, It’s not a valid cors request.

2012/9/11 n1xman [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

---

<div class="post-metadata">

**Author:** ![n1xman](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/13edae/32.png) [@n1xman](https://www.ruby-forum.com/u/n1xman)\
**Post date:** [September 17, 2012, 5:52pm UTC](https://www.ruby-forum.com/t/nginx-cross-origin-module-on-nginx-1-2-1/222794/3 "2012-09-17T17:52:54Z")

</div>

OK, It my bad. I checked with Origin request header and its working. 🙂

Thanks 姚伟斌 for the nice module and it works with nginx-1.2.1 too 🙂

Posted at Nginx Forum:

> **[Re: nginx\_cross\_origin\_module on nginx-1.2.1 - solved](https://forum.nginx.org/read.php?2,230641,230788#msg-230788)**
>
> Hi, We are trying to implement cross origin resource sharing protocol on our system. I just want to try nginx\_cross\_origin\_module and see how it work instead of add\_header approach. The issue is I can't see the CORS headers on the response headers....
