# 无法使用 GitHub 登录

**URL:** https://meta.discourse.org/t/cant-login-with-github/259253
**Category:** SSO
**Created:** [2023年三月24日 08:13 UTC](https://meta.discourse.org/t/cant-login-with-github/259253 "2023-03-24T08:13:27Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![yolwj](https://avatars.discourse-cdn.com/v4/letter/y/58f4c7/32.png) [@yolwj](https://meta.discourse.org/u/yolwj)
#### Post date: [2023年三月24日 08:13 UTC](https://meta.discourse.org/t/cant-login-with-github/259253/1 "2023-03-24T08:13:27Z")

</div>

我刚按照指南设置了 GitHub 登录：

> [@Configure GitHub login for Discourse](https://meta.discourse.org/t/configure-github-login-for-discourse/13745):
>
> bookmark This guide explains how to set up GitHub as a login option for your Discourse forum by configuring OAuth credentials. person_raising_hand Required user level: Administrator Overview GitHub login integration allows users to sign in to your Discourse site using their GitHub accounts. This provides a convenient authentication option, especially useful for developer-focused communities. Setting up GitHub OAuth Visit GitHub’s developer settings at https://github.com/settings/dev…

 ![image](https://global.discourse-cdn.com/meta/original/4X/7/1/d/71df9cef8a9922be7ffe5985cde375867ba1fd1d.png)

但登录失败了：

 ![image](https://global.discourse-cdn.com/meta/original/4X/c/3/7/c37839820adcf11d42b7e0968819bf1353fc3f86.png)

网络请求：

 ![image](https://global.discourse-cdn.com/meta/original/4X/d/0/b/d0bee20252ad25adf4772b26bbdf56735fb655a1.jpeg)

只是想知道我是否遗漏了什么？

---

<div class="post-metadata">

### Author: ![yolwj](https://avatars.discourse-cdn.com/v4/letter/y/58f4c7/32.png) [@yolwj](https://meta.discourse.org/u/yolwj)
#### Post date: [2023年三月24日 08:59 UTC](https://meta.discourse.org/t/cant-login-with-github/259253/2 "2023-03-24T08:59:14Z")

</div>

我在 `containers/app.yml` 中添加了端口映射，如下所示：

```plaintext
expose:
  - "20080:80" # http
  - "20443:443" # https

```

并使用 nginx 来转发 `forum.xxlang.com` 站点：

```plaintext
server {
     server_name forum.xxbitlang.com;
    location / {
                proxy_pass http://localhost:20080;
                proxy_set_header Host $host;
                proxy_set_header X-Real-IP $remote_addr;
    }
...
}

```

这是根本原因吗？

---

<div class="post-metadata">

### Author: ![RGJ](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/rgj/32/523185_2.png) [@RGJ](https://meta.discourse.org/u/RGJ)
#### Post date: [2023年三月24日 09:24 UTC](https://meta.discourse.org/t/cant-login-with-github/259253/3 "2023-03-24T09:24:08Z")

</div>

添加

```plaintext
proxy_set_header X-Forwarded-Proto https;

```
