You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@apisix.apache.org by GitBox <gi...@apache.org> on 2022/03/17 11:43:01 UTC
[GitHub] [apisix] kekoke opened a new issue #6648: help request: Use Nginx as proxy service, return 404 not found
kekoke opened a new issue #6648:
URL: https://github.com/apache/apisix/issues/6648
### Description
As subject, please refer to below information
Route config:
```
{
"uri": "/*",
"id": "sanctions",
"name": "sanctions",
"methods": [
"GET",
"POST",
"PUT",
"DELETE",
"PATCH",
"HEAD",
"OPTIONS"
],
"host": "uat-sanctions-api.com",
"upstream": {
"nodes": [
{
"host": "uat-sanctions-api.com",
"port": 80,
"weight": 1
}
],
"timeout": {
"connect": 6,
"send": 6,
"read": 6
},
"type": "roundrobin",
"checks": {
"active": {
"concurrency": 10,
"healthy": {
"http_statuses": [
200,
302
],
"interval": 1,
"successes": 2
},
"http_path": "/",
"port": 80,
"timeout": 1,
"type": "http",
"unhealthy": {
"http_failures": 5,
"http_statuses": [
429,
404,
500,
501,
502,
503,
504,
505
],
"interval": 1,
"tcp_failures": 2,
"timeouts": 3
}
}
},
"scheme": "http",
"pass_host": "pass",
"keepalive_pool": {
"idle_timeout": 60,
"requests": 1000,
"size": 320
}
},
"status": 1
}
```
![image](https://user-images.githubusercontent.com/17831817/158799338-62ff84c8-b0bc-4600-bf3b-a353415fafa5.png)
Nginx config:
![image](https://user-images.githubusercontent.com/17831817/158801157-43bfdccb-8220-44b5-aaac-444f1ce42bf7.png)
Postman testing:
![image](https://user-images.githubusercontent.com/17831817/158798776-6120f3e8-9dc2-41f6-a623-2549c2ea17d8.png)
When I direct to call API, the API service is ok:
![image](https://user-images.githubusercontent.com/17831817/158799794-6e1a64f3-f79b-4838-9d84-a181e3e43e83.png)
Could I how to fix this problem?
Thank you very much for your attention! -^-^
### Environment
- APISIX version (`2.12.0`):
- Operating system (`ubuntu`):
- Nginx version (`1.18.0`):
- etcd version, if relevant (`3.4.0`):
- APISIX Dashboard version, if relevant:
- Plugin runner version, for issues related to plugin runners:
- LuaRocks version, for installation issues (run `luarocks --version`):
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] kekoke commented on issue #6648: help request: Use Nginx as proxy service, return 404 not found
Posted by GitBox <gi...@apache.org>.
kekoke commented on issue #6648:
URL: https://github.com/apache/apisix/issues/6648#issuecomment-1072937571
Hi @tzssangglass, sorry for I have one more qunestion. I note that When I exclude --resolve parmeter in command, I will got the 404.
As I know Nginx will forward to http request of ```apigw-dev.com``` to ```127.0.0.1:9080(0.0.0.0:9080)``` in the Server, Why are we adding ```--resolve 'apigw-dev.com:80:127.0.0.1'``` into CURL request?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #6648: help request: Use Nginx as proxy service, return 404 not found
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #6648:
URL: https://github.com/apache/apisix/issues/6648#issuecomment-1071939757
1. as tokers said, you need to describe some clear;
2. show nginx.conf in text, not images;
3. use curl to trigger test, show the curl command in text;
These allow us to quickly reproduce the problem.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #6648: help request: Use Nginx as proxy service, return 404 not found
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #6648:
URL: https://github.com/apache/apisix/issues/6648#issuecomment-1071939757
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] kekoke commented on issue #6648: help request: Use Nginx as proxy service, return 404 not found
Posted by GitBox <gi...@apache.org>.
kekoke commented on issue #6648:
URL: https://github.com/apache/apisix/issues/6648#issuecomment-1072043781
Hi @tokers @tzssangglass thanks!
I am using Docker Compose for APISIX deployment, and using Nginx to proxy APISIX, the nginx configuration as below:
![image](https://user-images.githubusercontent.com/17831817/158935433-47dda36b-e365-4326-a9b8-e260c5468046.png)
![image](https://user-images.githubusercontent.com/17831817/158935964-e910ebd3-9126-4fc0-b6e8-f9eebcaaa333.png)
```
server {
listen 80;
server_name apigw-dev.com;
location / {
proxy_pass http://0.0.0.0:9080; # APISIX admin API
root /home/application;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
```
Create route:
```
curl --location --request PUT 'http://apigw-dev.com/apisix/admin/routes/' \
--header 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' \
--header 'Content-Type: application/json' \
--data-raw '{
"id": "sanctions",
"name": "sanctions",
"methods": [
"GET",
"POST",
"PUT"
],
"host": "uat-sanctions-api.com",
"uri": "/*",
"upstream": {
"type": "roundrobin",
"nodes": {
"uat-sanctions-api.com:80": 1
}
}
}'
```
Created route response:
![image](https://user-images.githubusercontent.com/17831817/158941815-96e141bb-5955-4f14-a247-1f4081565652.png)
Test ruote:
```
curl --location --request GET 'http://apigw-dev.com/api/account/info' \
--header 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' \
--header 'Host: uat-sanctions-api.com' \
```
Tested route response:
![image](https://user-images.githubusercontent.com/17831817/158941272-7cf2570f-eae6-4be7-b77a-51fd8b44fa05.png)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #6648: help request: Use Nginx as proxy service, return 404 not found
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #6648:
URL: https://github.com/apache/apisix/issues/6648#issuecomment-1073177059
You will need to check the meaning of the curl `--resolve` command yourself. Anyway, it is not relevant to this question.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tzssangglass commented on issue #6648: help request: Use Nginx as proxy service, return 404 not found
Posted by GitBox <gi...@apache.org>.
tzssangglass commented on issue #6648:
URL: https://github.com/apache/apisix/issues/6648#issuecomment-1072132860
my reproduction steps
1. nginx.conf
```nginx
server {
listen 80;
server_name apigw-dev.com;
location / {
proxy_pass http://0.0.0.0:9080; # APISIX admin API
proxy_set_header Host $host; # pass Host header to upstream, it's important
root /home/application;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
```
2. route config
```shell
$ curl --location --request PUT 'http://127.0.0.1:9080/apisix/admin/routes/' \
--header 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' \
--header 'Content-Type: application/json' \
--data-raw '{
"id": "sanctions",
"name": "sanctions",
"methods": [
"GET",
"POST",
"PUT"
],
"host": "uat-sanctions-api.com",
"uri": "/*",
"upstream": {
"type": "roundrobin",
"nodes": {
"httpbin.org:80": 1
}
}
}'
```
3. test
```shell
curl --location --request GET 'http://apigw-dev.com/get' \
--resolve 'apigw-dev.com:80:127.0.0.1' \
--header 'Host: uat-sanctions-api.com'
```
Since you set the host match in the APISIX route via `"host": "uat-sanctions-api.com"`, but your nginx does not pass the `Host` in the client request header, you need to add `proxy_set_header Host $host;`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] kekoke commented on issue #6648: help request: Use Nginx as proxy service, return 404 not found
Posted by GitBox <gi...@apache.org>.
kekoke commented on issue #6648:
URL: https://github.com/apache/apisix/issues/6648#issuecomment-1072927133
> my reproduction steps
>
> 1. nginx.conf
>
> ```nginx
> server {
> listen 80;
> server_name apigw-dev.com;
>
> location / {
> proxy_pass http://0.0.0.0:9080; # APISIX admin API
> proxy_set_header Host $host; # pass Host header to upstream, it's important
> root /home/application;
> index index.html index.htm;
> }
>
> error_page 500 502 503 504 /50x.html;
> location = /50x.html {
> root html;
> }
>
> }
> ```
>
> 2. route config
>
> ```shell
> $ curl --location --request PUT 'http://127.0.0.1:9080/apisix/admin/routes/' \
> --header 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' \
> --header 'Content-Type: application/json' \
> --data-raw '{
> "id": "sanctions",
> "name": "sanctions",
> "methods": [
> "GET",
> "POST",
> "PUT"
> ],
> "host": "uat-sanctions-api.com",
> "uri": "/*",
> "upstream": {
> "type": "roundrobin",
> "nodes": {
> "httpbin.org:80": 1
> }
> }
> }'
> ```
>
> 3. test
>
> ```shell
> curl --location --request GET 'http://apigw-dev.com/get' \
> --resolve 'apigw-dev.com:80:127.0.0.1' \
> --header 'Host: uat-sanctions-api.com'
> ```
>
> Since you set the host match in the APISIX route via `"host": "uat-sanctions-api.com"`, but your nginx does not pass the `Host` in the client request header, you need to add `proxy_set_header Host $host;`
@tzssangglass It is ok for me too. Thank you so much! have a nice weekend -^-^
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] kekoke closed issue #6648: help request: Use Nginx as proxy service, return 404 not found
Posted by GitBox <gi...@apache.org>.
kekoke closed issue #6648:
URL: https://github.com/apache/apisix/issues/6648
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tokers commented on issue #6648: help request: Use Nginx as proxy service, return 404 not found
Posted by GitBox <gi...@apache.org>.
tokers commented on issue #6648:
URL: https://github.com/apache/apisix/issues/6648#issuecomment-1071934025
Could you describe your API topology clearly? Is nginx the backend of apisix?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] kekoke commented on issue #6648: help request: Use Nginx as proxy service, return 404 not found
Posted by GitBox <gi...@apache.org>.
kekoke commented on issue #6648:
URL: https://github.com/apache/apisix/issues/6648#issuecomment-1072043781
Hi @tokers @tzssangglass thanks!
I am using Docker Compose for APISIX deployment, and using Nginx to proxy APISIX, the nginx configuration as below:
![image](https://user-images.githubusercontent.com/17831817/158935433-47dda36b-e365-4326-a9b8-e260c5468046.png)
![image](https://user-images.githubusercontent.com/17831817/158935964-e910ebd3-9126-4fc0-b6e8-f9eebcaaa333.png)
```
server {
listen 80;
server_name apigw-dev.com;
location / {
proxy_pass http://0.0.0.0:9080; # APISIX admin API
root /home/application;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
```
Create route:
```
curl --location --request PUT 'http://apigw-dev.com/apisix/admin/routes/' \
--header 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' \
--header 'Content-Type: application/json' \
--data-raw '{
"id": "sanctions",
"name": "sanctions",
"methods": [
"GET",
"POST",
"PUT"
],
"host": "uat-sanctions-api.com",
"uri": "/*",
"upstream": {
"type": "roundrobin",
"nodes": {
"uat-sanctions-api.com:80": 1
}
}
}'
```
Created route response:
![image](https://user-images.githubusercontent.com/17831817/158941815-96e141bb-5955-4f14-a247-1f4081565652.png)
Test ruote:
```
curl --location --request GET 'http://apigw-dev.com/api/account/info' \
--header 'X-API-KEY: edd1c9f034335f136f87ad84b625c8f1' \
--header 'Host: uat-sanctions-api.com' \
```
Tested route response:
![image](https://user-images.githubusercontent.com/17831817/158941272-7cf2570f-eae6-4be7-b77a-51fd8b44fa05.png)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] tokers commented on issue #6648: help request: Use Nginx as proxy service, return 404 not found
Posted by GitBox <gi...@apache.org>.
tokers commented on issue #6648:
URL: https://github.com/apache/apisix/issues/6648#issuecomment-1071934025
Could you describe your API topology clearly? Is nginx the backend of apisix?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [apisix] kekoke commented on issue #6648: help request: Use Nginx as proxy service, return 404 not found
Posted by GitBox <gi...@apache.org>.
kekoke commented on issue #6648:
URL: https://github.com/apache/apisix/issues/6648#issuecomment-1073399623
> You will need to check the meaning of the curl `--resolve` command yourself. Anyway, it is not relevant to this question.
Yes, I see. Thanks again. -^-^
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@apisix.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org