【问题标题】:asp.net core app not working with Auth0 authentication in productionasp.net 核心应用程序无法在生产中使用 Auth0 身份验证
【发布时间】:2017-07-16 14:44:48
【问题描述】:

我正在为我的一个 .net 核心应用程序使用 Auth0 身份验证。为了将 Auth0 与我的应用程序集成,我完全按照此处提供的教程 https://auth0.com/docs/quickstart/webapp/aspnet-core

在开发环境中,一切正常。换句话说,Auth0 身份验证被正确调用,我被重定向到我的应用程序。

在生产环境中,事情并不是那么顺利。发送到 Auth0 的重定向 URI 是 http://localhost/signin-auth0,而它应该类似于 http://mydomainname.com/signin-auth0

同样在生产中,我使用 nginx 作为反向代理,以便将 http://mydomainname.com:80 重定向到 http://localhost:5000,这是 kestrel 绑定的地址。

我的问题:

  • 我应该在 nginx 中配置什么特定的东西,以便将重定向 URL 正确传递给 Auth0?

  • 在哪里可以指定/强制将重定向 URL 传递给 Auth0?

我的nginx配置很基础:

http {

    sendfile on;

    gzip              on;
    gzip_http_version 1.0;
    gzip_proxied      any;
    gzip_min_length   500;
    gzip_disable      "MSIE [1-6]\.";
    gzip_types        text/plain text/xml text/css
                      text/comma-separated-values
                      text/javascript
                      application/x-javascript
                      application/atom+xml;

    # List of application servers
    upstream kestrel {

        server localhost:5000;

    }


    # Configuration for the server
    server {
        # Running port
        listen *:80;
        # index index.html;
        # root /usr/share/nginx/html;
        location / {
           proxy_pass http://kestrel;
           proxy_http_version 1.1;
           proxy_set_header Upgrade $http_upgrade;
           proxy_set_header Connection keep-alive;
           proxy_set_header Host localhost;
           proxy_set_header X-Forwarded-For $remote_addr;
           proxy_cache_bypass $http_upgrade;
        }
    }
}

【问题讨论】:

    标签: nginx asp.net-core auth0


    【解决方案1】:

    好的,想通了!我的 nginx 配置搞砸了:

    proxy_set_header Host localhost; 应改为 proxy_set_header Host mydomainname.com;

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2017-01-04
      • 2021-06-11
      • 1970-01-01
      • 2021-10-15
      • 2017-05-13
      • 2020-05-14
      • 2019-08-05
      相关资源
      最近更新 更多