Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用问题 #261

Open
Futurefangyuan opened this issue Apr 7, 2023 · 4 comments
Open

使用问题 #261

Futurefangyuan opened this issue Apr 7, 2023 · 4 comments

Comments

@Futurefangyuan
Copy link

安装方式

Docker 安装=

问题描述

使用nginx代理后端docker的映射端口,配置域名及https访问,后端接口报405

12

@yoonper
Copy link
Collaborator

yoonper commented Apr 7, 2023

方便贴一下 Nginx 配置吗

@yoonper
Copy link
Collaborator

yoonper commented Apr 7, 2023

可以看下 /api/login 请求的响应内容是什么
码小六路由配置这个接口是 POST 请求,反向代理时是否有误

@Futurefangyuan
Copy link
Author

location / {
proxy_pass http://CodeMon;
proxy_redirect http:// https://;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header HTTP_X_FORMARDED_FOR $remote_addr;
proxy_buffers 8 16k;
proxy_cookie_path / "/; Path=/; Secure; HttpOnly";
proxy_buffer_size 32k;
}

location /api/ {
proxy_pass http://172.20.5.8:8081/;
proxy_method POST;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
error_page 405 =200 $uri;
if ($request_method = 'OPTIONS') {
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Credentials true;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
}
if ($request_method = 'POST') {
add_header 'Access-Control-Allow-Origin' *;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
}
if ($request_method = 'GET') {
add_header 'Access-Control-Allow-Origin' *;
add_header 'Access-Control-Allow-Credentials' 'true';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
}
}

@Futurefangyuan
Copy link
Author

Futurefangyuan commented Apr 7, 2023

后端日志,直接返回:
192.168.150.4 - - [06/Apr/2023:20:52:21 +0800] "POST /api/login HTTP/1.1" 405 99 "http://codemon.xxx.com/login" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/111.0.0.0 Safari/537.36" "-"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants