我正在尝试使用 Oauth2-proxy 作为通过 Google 身份验证访问我的网站的网关。出现 Oauth 登录页面,您可以单击“登录”,这会将您带到 Google 登录页面,但登录后会直接重定向回 Oauth 登录页面。我怀疑这与cookie有关,但我不知道我哪里出错了。
NGINX 配置:
server {
listen 443;
server_name my.website.com;
ssl on;
ssl_certificate /etc/ssl/my.website.com.pem;
ssl_certificate_key /etc/ssl/my.website.com.key;
location /oauth2/ {
proxy_pass http://127.0.0.1:4180;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header X-Auth-Request-Redirect $request_uri;
}
location = /oauth2/auth {
proxy_pass http://127.0.0.1:4180;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header Content-Length "";
proxy_pass_request_body off;
}
location / {
auth_request /oauth2/auth;
error_page 401 = /oauth2/sign_in;
# pass information via X-User and X-Email …Run Code Online (Sandbox Code Playgroud) 我正在尝试让 ZeroMQ 在我的网络应用程序中工作。在前端,我使用的是 JSZMQ 库,它应该在浏览器中工作(我知道大多数库都不能)。在Python后端,我使用zmq。问题是我尝试的所有协议都会抛出错误。如果我尝试 TCP,正如预期的那样,浏览器会抛出一个错误,指出“不支持的传输”。
根据这个SO问题,当协议为“ws://”时,JSZMQ应该工作。当我尝试此操作时,服务器在运行时立即抛出“协议不支持”错误。这是我的代码:
客户:
import * as zmq from 'jszmq'
const socket = new zmq.Pull()
socket.connect('ws://127.0.0.1:3000')
socket.on('message', msg => console.log(msg))
Run Code Online (Sandbox Code Playgroud)
服务器:
import zmq
context = zmq.Context()
sock = context.socket(zmq.PUSH)
sock.bind('ws://127.0.0.1:3000') # This is what throws the error
sock.send('hello')
Run Code Online (Sandbox Code Playgroud)
如果重要的话,我正在为服务器进行多重处理,并将 zmq 对象作为全局对象,因为它不可序列化,并且无法作为参数传递到函数中。
为什么这不起作用?