嘿,我有一个Rails应用程序,我已经redirect几乎所有stream量使用https。 但是,我的应用程序中有一个特定的path,我需要通过纯http访问,比如somedomain.com/special 。
我想知道这是甚至可能的,因为我的Rails应用程序似乎在https块中定义。 也许如果有一些方法可以在http和https上进行托pipe,那么如果不是/special话,将所有stream量从httpredirect到https? (我也需要/RPC2在http上,但这不是一个轨道path,这就是为什么现在工作)。
任何build议,我将不胜感激。 如果您在configuration中看到任何明显的错误,如果您指出这些错误,我也会很感激!
server { listen 80; server_name somedomain.com; location / { rewrite ^ https://somedomain.com$request_uri? permanent; } location /RPC2 { include scgi_params; scgi_pass 127.0.0.1:5000; auth_basic "app"; auth_basic_user_file /var/www/server/basic.auth; } } server { listen 443 default ssl; server_name somedomain.com; root /var/www/sites/app/current/public; passenger_enabled on; rails_env production; ssl_certificate /etc/ssl/certs/myssl.crt; ssl_certificate_key /etc/ssl/certs/myssl.key; ssl_protocols SSLv2 SSLv3 TLSv1; ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP; location /downloads { autoindex on; autoindex_exact_size off; auth_basic "node"; auth_basic_user_file /var/www/server/basic.auth; alias /var/www/downloads/; } }
再次感谢!
我想你可以通过proxy_passing到https服务器。
服务器{
听80;
位置/特殊{
proxy_pass https:// localhost:443;
proxy_set_header X-Real-IP $ remote_addr;
}
}
如果它适用于您,请检查应用程序和nginx访问日志以获取/特殊请求。 如果logging的IP是127.0.0.1,则启用nginx的http_realip模块并添加
set_real_ip_from 127.0.0.1; real_ip_header X-Real-IP;
在SSL服务器configuration。