简体   繁体   English

Nginx重定向以登录

[英]Nginx redirect to sign in

My proxy pass go in example:7456/nix/sign_in, but when I type login and password, and click submit button server not stay on example:7456/nix/sign_in and redirect to example:7456/sign_in. 我的代理服务器通行证例如:7456 / nix / sign_in,但是当我键入登录名和密码并单击“提交”按钮时,服务器不会停留在例如:7456 / nix / sign_in上,并重定向到例如:7456 / sign_in。

  server {
    listen 7456;
    charset utf-8;
    server_name example;
    root /home/support/project_test/public;
    passenger_enabled on;
    rails_env development;

    location /nix/ {
        root /home/support/project_nginx/public;
        passenger_base_uri /nix/;
        passenger_enabled on;
        #include proxy_params;
        proxy_pass http://10.77.92.167:7458/;
        #proxy_set_header X-Accel-Redirect;
        proxy_pass_header X-Accel-Redirect;
        proxy_set_header Content-Length 0;
        proxy_set_header Host $host;
        proxy_redirect off;
    }
}
server {
    listen 7458;
    charset utf-8;
    server_name example;
    root /home/support/project_nginx/public;
    passenger_enabled on;
    rails_env development;
}

How can I fix redirect and stay example:7456/nix/ — on proxy pass. 如何修复重定向并保留示例:7456 / nix /-通过代理传递。

I use Nginx, Passenger and Ruby on Rails. 我使用Nginx,Passenger和Ruby on Rails。

First go to environment.rb 首先去environment.rb

ENV['RAILS_RELATIVE_URL_ROOT'] = "/nix/"

Second config.ru 第二config.ru

map '/nix/' do
  run App::Application
end

And next nginx.conf 接下来的nginx.conf

location /nix/ {
   proxy_pass http://example:7458/nix/;
   proxy_set_header Host $host;
}

Type http://example:7456/nix/sign_in , and you did'n get redirect to another page, when click submit button. 键入http://example:7456/nix/sign_in ,单击“提交”按钮后,您没有重定向到另一页。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM