Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ruby-on-rails-3/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 3 nginx重写/代理\传递问题_Ruby On Rails 3_Url Rewriting_Nginx_Passenger_Proxypass - Fatal编程技术网

Ruby on rails 3 nginx重写/代理\传递问题

Ruby on rails 3 nginx重写/代理\传递问题,ruby-on-rails-3,url-rewriting,nginx,passenger,proxypass,Ruby On Rails 3,Url Rewriting,Nginx,Passenger,Proxypass,我做了一些广泛的搜索,有相当多的关于nginx proxy_pass问题的帖子。我试着把我的问题修改成这些问题中的一些,但没有任何进展 我正在将一个基于php的网站改写成Rails。原来的网站本身是简单的2页表单。它在Apache中使用mod_rewrite/mod_代理解决方案来屏蔽表单发布后站点继续运行的url php站点有3个目录,其中只有3个.htaccess文件。为了简单起见,让我们调用目录a、b、c。每个.htaccess文件都包含以下内容 <IfModule mod_rewr

我做了一些广泛的搜索,有相当多的关于nginx proxy_pass问题的帖子。我试着把我的问题修改成这些问题中的一些,但没有任何进展

我正在将一个基于php的网站改写成Rails。原来的网站本身是简单的2页表单。它在Apache中使用mod_rewrite/mod_代理解决方案来屏蔽表单发布后站点继续运行的url

php站点有3个目录,其中只有3个.htaccess文件。为了简单起见,让我们调用目录a、b、c。每个.htaccess文件都包含以下内容

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteRule ^(.*)$ http://www.domainbeingpostedto.com/actual_letter_directory/$1 [P,L]
</IfModule>

重新启动发动机
重写规则^(.*)$http://www.domainbeingpostedto.com/actual_letter_directory/$1[P,L]
我不是apache专家,但我非常确定[p,L]与proxy_pass相同,并且是nginx中的最后一个

我正在尝试为php站点重写这个解决方案,该站点使用passenger和nginx转换为rails cms

到目前为止,我的解决方案不起作用,因为rails应用程序只返回404,而页面未找到,所以我知道proxy_pass没有将post请求转发到其他服务器。 我的nginx.conf文件有:

server {
    listen 80;
    server_name newtestappdomain.com;

    location /a/ {
        proxy_pass http://www.domaintoacceptdatapostandbemasked.com/;
        #rewrite ^/a/(.*)$ http://www.domaintoacceptdatapostandbemaskedcom/a/ last;
    }

    location /b/ {
        proxy_pass http://www.domaintoacceptdatapostandbemasked.com/;
        #rewrite ^/b/(.*)$ http://www.domaintoacceptdatapostandbemasked.com/b/ last;
    }

    location /c/ {
        proxy_pass http://www.domaintoacceptdatapostandbemasked.com/;
        #rewrite ^/c/(.*)$ http://www.domaintoacceptdatapostandbemasked.com/c/ last;

    }

    root /home/deploy/testapp/public;   # <--- be sure to point to 'public'!
    passenger_enabled on;

}
服务器{
听80;
服务器名称newtestappdomain.com;
地点/a/{
代理通行证http://www.domaintoacceptdatapostandbemasked.com/;
#重写^/a/(.*)$http://www.domaintoacceptdatapostandbemaskedcom/a/ 最后;
}
地点/b/{
代理通行证http://www.domaintoacceptdatapostandbemasked.com/;
#重写^/b/(.*)$http://www.domaintoacceptdatapostandbemasked.com/b/ 最后;
}
地点/c/{
代理通行证http://www.domaintoacceptdatapostandbemasked.com/;
#重写^/c/(.*)$http://www.domaintoacceptdatapostandbemasked.com/c/ 最后;
}
root/home/deploy/testapp/public;#
此规则将是对“/”位置的代理请求(代理传递uri中的前导斜杠)(a/、b/和c/将丢失)

只需使用uri而不使用前导斜杠,它应该可以完美地工作

proxy_pass http://www.domaintoacceptdatapostandbemasked.com;
如果您需要更改uri,可以在代理传递之前使用“重写”。 例如:

location /a/ {
    rewrite /(a/.*)$ /actual_letter_directory/$1 break; # as from you .htaccess example
}
location /a/ {
    rewrite /(a/.*)$ /actual_letter_directory/$1 break; # as from you .htaccess example
}