在NGINX前向代理后面运行IdentityServer3

时间:2016-01-28 14:19:42

标签: asp.net-mvc-4 nginx identityserver3

我正在尝试将代理和.NET MVC应用程序转发给NGINX后面的IdentityServer3。作为概念证明,我在笔记本上的VirtualBox VM中运行NGINX。登录过程似乎正常工作,直到我对用户进行身份验证并重定向到应用程序之后。在打开IdentityServer3的所有日志记录后,我可以看到没有返回错误,我希望创建的令牌被创建等等。但是我也注意到,当登录的响应消息没有设置.AspNet.Cookies cookie时。我相信这就是问题。

我怀疑在我的环境中这是一种愚蠢的设置问题。我在我的Windows主机文件中将虚拟机的IP地址定义为goober.mydomain.com。我的NGINX配置文件如下。有没有人注意到我做错了什么?

    user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {

    server {

            large_client_header_buffers 4 32k;

            location /phoenix {
                    rewrite ^/phoenix(.*) /$1 break;

                    proxy_pass http://USSTP90000005/;
            }

            location /api/i19n {
                    proxy_pass http://USSTP90000005:83/;
            }

            location /api/login {
                    proxy_pass http://USSTP90000005:84/api/login;
            }

            location /api/users {
                    proxy_pass http://USSTP90000005:84/;
            }

            location /id {

                    rewrite ^/id(.*) /$1 break;

                    proxy_pass http://USSTP90000005:84/;

                    proxy_cookie_path   /identity /;
            }

            location /identity {
                    proxy_pass http://USSTP90000005:84/identity/;
            }

            location /templates {
                    proxy_pass http://USSTP90000005:84/templates/;
            }

            location /bundles {
                    proxy_pass http://USSTP90000005:84/bundles/;
            }

}

#include /etc/nginx/conf.d/*.conf;
#include       /etc/nginx/mime.types;
#default_type  application/octet-stream;

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
              '$status $body_bytes_sent "$http_referer" '
              '"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;

sendfile        on;
#tcp_nopush     on;

keepalive_timeout  65;

#gzip  on;

1 个答案:

答案 0 :(得分:0)

我对NGinx并不太熟悉,但你似乎并没有在它和它之间做过什么。这些网站。这可能是您遇到麻烦的原因,因为Identity Server&客户希望使用SSL。您可能需要禁用ssl要求,但是然后让NGinx在它之间执行SSL。浏览器。

相关问题