HTTP Origin header (https://example.com) didn't match request.base_url (http://example.com) rails












0














I am running Nginx server with the puma on https. I configured Letsencrypt for SSL verification. The problem is that the server is running fine but when I try to create a user through devise it throws this error



"HTTP Origin header (https://example.com) didn't match request.base_url (http://example.com)"



I tried to modify the nginx.conf configuration as specified over here
https://github.com/rails/rails/issues/22965#issuecomment-172929004



but still, no luck here is my configuration file



upstream puma {

server unix:///home/ubuntu/blue_whale/example/shared/tmp/sockets/gofickle-puma.sock;
}

server
{
listen 443 ssl default;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

root /home/ubuntu/blue_whale/example/current/public;
access_log /home/ubuntu/blue_whale/example/current/log/nginx.access.log;
error_log /home/ubuntu/blue_whale/example/current/log/nginx.error.log info;

add_header Strict-Transport-Security “max-age=31536000”;


location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}

try_files $uri/index.html $uri @puma;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Ssl on; # Optional
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Host $host;

proxy_pass http://puma;
}









share|improve this question
























  • Possibly stupid question, but I know there are some nginx options that are order dependent: have you tried putting the proxy_pass before the proxy_set_header's? That's the only obvious difference I see between your config and the one you referenced.
    – Chris Hall
    Nov 20 at 19:39










  • @chrisHall I dont think, it is order dependent but still I tried and it didnt work.
    – Ashish Jambhulkar
    Nov 20 at 19:44
















0














I am running Nginx server with the puma on https. I configured Letsencrypt for SSL verification. The problem is that the server is running fine but when I try to create a user through devise it throws this error



"HTTP Origin header (https://example.com) didn't match request.base_url (http://example.com)"



I tried to modify the nginx.conf configuration as specified over here
https://github.com/rails/rails/issues/22965#issuecomment-172929004



but still, no luck here is my configuration file



upstream puma {

server unix:///home/ubuntu/blue_whale/example/shared/tmp/sockets/gofickle-puma.sock;
}

server
{
listen 443 ssl default;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

root /home/ubuntu/blue_whale/example/current/public;
access_log /home/ubuntu/blue_whale/example/current/log/nginx.access.log;
error_log /home/ubuntu/blue_whale/example/current/log/nginx.error.log info;

add_header Strict-Transport-Security “max-age=31536000”;


location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}

try_files $uri/index.html $uri @puma;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Ssl on; # Optional
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Host $host;

proxy_pass http://puma;
}









share|improve this question
























  • Possibly stupid question, but I know there are some nginx options that are order dependent: have you tried putting the proxy_pass before the proxy_set_header's? That's the only obvious difference I see between your config and the one you referenced.
    – Chris Hall
    Nov 20 at 19:39










  • @chrisHall I dont think, it is order dependent but still I tried and it didnt work.
    – Ashish Jambhulkar
    Nov 20 at 19:44














0












0








0







I am running Nginx server with the puma on https. I configured Letsencrypt for SSL verification. The problem is that the server is running fine but when I try to create a user through devise it throws this error



"HTTP Origin header (https://example.com) didn't match request.base_url (http://example.com)"



I tried to modify the nginx.conf configuration as specified over here
https://github.com/rails/rails/issues/22965#issuecomment-172929004



but still, no luck here is my configuration file



upstream puma {

server unix:///home/ubuntu/blue_whale/example/shared/tmp/sockets/gofickle-puma.sock;
}

server
{
listen 443 ssl default;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

root /home/ubuntu/blue_whale/example/current/public;
access_log /home/ubuntu/blue_whale/example/current/log/nginx.access.log;
error_log /home/ubuntu/blue_whale/example/current/log/nginx.error.log info;

add_header Strict-Transport-Security “max-age=31536000”;


location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}

try_files $uri/index.html $uri @puma;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Ssl on; # Optional
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Host $host;

proxy_pass http://puma;
}









share|improve this question















I am running Nginx server with the puma on https. I configured Letsencrypt for SSL verification. The problem is that the server is running fine but when I try to create a user through devise it throws this error



"HTTP Origin header (https://example.com) didn't match request.base_url (http://example.com)"



I tried to modify the nginx.conf configuration as specified over here
https://github.com/rails/rails/issues/22965#issuecomment-172929004



but still, no luck here is my configuration file



upstream puma {

server unix:///home/ubuntu/blue_whale/example/shared/tmp/sockets/gofickle-puma.sock;
}

server
{
listen 443 ssl default;
server_name example.com;
ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

root /home/ubuntu/blue_whale/example/current/public;
access_log /home/ubuntu/blue_whale/example/current/log/nginx.access.log;
error_log /home/ubuntu/blue_whale/example/current/log/nginx.error.log info;

add_header Strict-Transport-Security “max-age=31536000”;


location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}

try_files $uri/index.html $uri @puma;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Ssl on; # Optional
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Host $host;

proxy_pass http://puma;
}






ruby-on-rails ruby nginx puma nginx-config






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 21 at 7:31









Ravi Mariya

934716




934716










asked Nov 20 at 19:31









Ashish Jambhulkar

432415




432415












  • Possibly stupid question, but I know there are some nginx options that are order dependent: have you tried putting the proxy_pass before the proxy_set_header's? That's the only obvious difference I see between your config and the one you referenced.
    – Chris Hall
    Nov 20 at 19:39










  • @chrisHall I dont think, it is order dependent but still I tried and it didnt work.
    – Ashish Jambhulkar
    Nov 20 at 19:44


















  • Possibly stupid question, but I know there are some nginx options that are order dependent: have you tried putting the proxy_pass before the proxy_set_header's? That's the only obvious difference I see between your config and the one you referenced.
    – Chris Hall
    Nov 20 at 19:39










  • @chrisHall I dont think, it is order dependent but still I tried and it didnt work.
    – Ashish Jambhulkar
    Nov 20 at 19:44
















Possibly stupid question, but I know there are some nginx options that are order dependent: have you tried putting the proxy_pass before the proxy_set_header's? That's the only obvious difference I see between your config and the one you referenced.
– Chris Hall
Nov 20 at 19:39




Possibly stupid question, but I know there are some nginx options that are order dependent: have you tried putting the proxy_pass before the proxy_set_header's? That's the only obvious difference I see between your config and the one you referenced.
– Chris Hall
Nov 20 at 19:39












@chrisHall I dont think, it is order dependent but still I tried and it didnt work.
– Ashish Jambhulkar
Nov 20 at 19:44




@chrisHall I dont think, it is order dependent but still I tried and it didnt work.
– Ashish Jambhulkar
Nov 20 at 19:44












1 Answer
1






active

oldest

votes


















0














I have the exact same setup as you and mine is working with the below proxy config:



  location @rails {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://rails_app;
}


I think it might be the X-Forwarded-Proto and SSL that might be causing your issue, it isn't necessary behind the proxy.






share|improve this answer





















    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400247%2fhttp-origin-header-https-example-com-didnt-match-request-base-url-http-e%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    I have the exact same setup as you and mine is working with the below proxy config:



      location @rails {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
    proxy_pass http://rails_app;
    }


    I think it might be the X-Forwarded-Proto and SSL that might be causing your issue, it isn't necessary behind the proxy.






    share|improve this answer


























      0














      I have the exact same setup as you and mine is working with the below proxy config:



        location @rails {
      proxy_set_header X-Real-IP $remote_addr;
      proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
      proxy_set_header Host $http_host;
      proxy_redirect off;
      proxy_pass http://rails_app;
      }


      I think it might be the X-Forwarded-Proto and SSL that might be causing your issue, it isn't necessary behind the proxy.






      share|improve this answer
























        0












        0








        0






        I have the exact same setup as you and mine is working with the below proxy config:



          location @rails {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://rails_app;
        }


        I think it might be the X-Forwarded-Proto and SSL that might be causing your issue, it isn't necessary behind the proxy.






        share|improve this answer












        I have the exact same setup as you and mine is working with the below proxy config:



          location @rails {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_pass http://rails_app;
        }


        I think it might be the X-Forwarded-Proto and SSL that might be causing your issue, it isn't necessary behind the proxy.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Nov 20 at 20:51









        DivXZero

        3881515




        3881515






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53400247%2fhttp-origin-header-https-example-com-didnt-match-request-base-url-http-e%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Wiesbaden

            Marschland

            Dieringhausen