Nginx_cross_origin_module on nginx-1.2.1

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:

HI,

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

2012/9/11 n1xman [email protected]:

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

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

Posted at Nginx Forum: