5

this is an issue with Nginx that affects only firefox. I have this config: http://pastebin.com/q6Yeqxv9

upstream connect {
        server 127.0.0.1:8080;
}

server {
        server_name admin.example.com www.admin.example.com;
        listen 80;
        return 301 https://admin.example.com$request_uri;
}

server {
        listen 80;
        server_name ankieta.example.com www.ankieta.example.com;
        add_header Access-Control-Allow-Origin $http_origin;
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, PATCH, DELETE';
        add_header 'Access-Control-Allow-Credentials' 'true';
        add_header 'Access-Control-Allow-Headers' 'Access-Control-Request-Method,Access-Control-Request-Headers,Cache,Pragma,Authorization,Accept,Accept-Encoding,Accept-Language,Host,Referer,Content-Length,Origin,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';
        return 301 https://ankieta.example.com$request_uri;
}

server {
        server_name admin.example.com;
        listen 443 ssl;
        ssl_certificate /srv/ssl/14182263.pem;
        ssl_certificate_key /srv/ssl/admin_i_ankieta.example.com.key;

        ssl_protocols SSLv3 TLSv1;
        ssl_ciphers ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM;

        location / {
                proxy_pass http://connect;
        }
}

server {
        server_name ankieta.example.com;
        listen 443 ssl;
        ssl_certificate /srv/ssl/14182263.pem;
        ssl_certificate_key /srv/ssl/admin_i_ankieta.example.com.key;

        ssl_protocols SSLv3 TLSv1;
        ssl_ciphers ALL:!aNULL:!ADH:!eNULL:!LOW:!EXP:RC4+RSA:+HIGH:+MEDIUM;

        root /srv/limesurvey;
        index index.php;

        add_header 'Access-Control-Allow-Origin' $http_origin;
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT, PATCH, DELETE';
        add_header 'Access-Control-Allow-Credentials' 'true';
        add_header 'Access-Control-Allow-Headers' 'Access-Control-Request-Method,Access-Control-Request-Headers,Cache,Pragma,Authorization,Accept,Accept-Encoding,Accept-Language,Host,Referer,Content-Length,Origin,DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type';

        client_max_body_size 4M;

        location / {
                try_files $uri $uri/ /index.php?q=$uri&$args;
        }

        location ~ /*.php$ {

                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                #NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME /srv/limesurvey$fastcgi_script_name;
#                       fastcgi_param HTTPS $https;
                fastcgi_intercept_errors on;
                fastcgi_pass 127.0.0.1:9000;
        }

        location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                expires max;
                log_not_found off;
        }


}

this is basically an AngularJS app and a PHP app (LimeSurvey), served under two different domains by the same webserver (Nginx). AngularJS is in fact served by ConnectJS, which is proxied to by Nginx (ConnectJS listens only on localhost).

In Firefox console I get this:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://ankieta.example.com/admin/remotecontrol. This can be fixed by moving the resource to the same domain or enabling CORS.

which of course is annoying. Other browsers work fine (Chrome, IE).

Any suggestions on this?

2
  • Did you get anywhere with this? I have the same problem and I'm just going round in circles. It's only Firefox and it just gives them same stupid error message regardless of what's going on.
    – toxaq
    Jul 13, 2014 at 9:39
  • right, so what I did was I needed to authorize the backend, the ssl cert for the remotecontrol api wasn't trusted by firefox (just navigate to the /remotecontrol endpoint with firefox and trust the cert). I also got the latest Nginx. that still didn't solve the problem, as Firefox sends hard-coded Content-Type headers. I did manage to get it working though, see this post stackoverflow.com/questions/24465304/…
    – wiherek
    Jul 14, 2014 at 8:19

1 Answer 1

2

the problem was happening because Firefox didn't authorize the API's SSL cert. Trusting the site's cert by navigating to the endpoint with Firefox solved the issues temporarily, while changing the cert - permanently.

Header issues with Firefox and LimeSurvey remotecontrol API can be fixed by proxying fixed header values, or sending blobs, as per https://stackoverflow.com/questions/24465304/trouble-changing-request-headers-in-firefox-with-angularjs

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .