如何使用Auth0设置Nginx? [英] How to setup Nginx with Auth0?
问题描述
我在端口3000上运行了一个应用程序.
I got an app running in port 3000.
此应用正在反向代理(如:
this app is working behind a reverse proxy such as:
server {
listen 80;
server_name myapp;
location / {
proxy_pass http://127.0.0.1:3000;
}
}
因此,每次我访问我的网站时,它将用于将端口3000上的内容本地化,并且工作正常.
so, everytime I access to my site, it will serve to localhost the content from port 3000, and it's working ok.
问题是在auth0身份验证之后,当用户通过身份验证后,它会继续重定向到localhost:3000/#,我如何使它工作到localhost?
The problem is after the auth0 authentication, when the user is authenticated it keeps redirecting to localhost:3000/#, how can I make it work to localhost?
这是我的Nginx配置文件:
this is my Nginx config file:
server {
listen 80;
server_name myapp;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
}
location /generic_oauth/ {
proxy_pass http://127.0.0.1:3000;
}
}
回调为localhost/login/generic_oauth
我的auth0设置回调为:http://localhost:3000/login/generic_oauth
my auth0 settings callback is: http://localhost:3000/login/generic_oauth
如果我将auth0回调更改为http://localhost/login/generic_oauth
if I change my auth0 callback to http://localhost/login/generic_oauth
得到错误:
对不起,我的英语不好
推荐答案
应用程序必须知道要在其发布的URL上使用哪个域名. nginx可能还需要做一些重写.
The application has to know what domain name to use on the URLs it issues. nginx may also need to do some rewriting.
按照此处的说明添加X-Forwarded-Host标头,并可能添加proxy_redirect指令
Add an X-Forwarded-Host header, and potentially a proxy_redirect directive, as per instructions here
https://www.nginx.com/resources/Wiki/start/topics/examples/likeapache/
这篇关于如何使用Auth0设置Nginx?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!