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 2020/10/19 08:21:40 UTC

[GitHub] [apisix] lizeming opened a new issue #2468: request help:

lizeming opened a new issue #2468:
URL: https://github.com/apache/apisix/issues/2468


   ### Issue description
       Hello, we are APISIX users. Currently using APISIX unified Internet proxy service. We have a requirement that we need to use the same Internet IP address and different ports to differentiate services, and use a reverse proxy to the back-end service. The back-end service will return the ‘Host’ address in the request header as the host address of the URL to the client. However, we found that the ‘Host’ requested by the client has a port, but APISIX will be modified to an address without a port to the back-end service, causing the back-end service to return an incorrect address and cause an access error. Header rewriting via proxy_rewrite plug-in does not take effect. How do I solve this situation? Is it reasonable for APISIX to remove the port from the ‘Host’ address?
   
   ### Environment
   
   * apisix version (cmd: `apisix version`): 1.5
   * OS: Redhat Linux 7.4 x64
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] lizeming commented on issue #2468: request help: The problem of rewriting HTTP request header ‘Host’

Posted by GitBox <gi...@apache.org>.
lizeming commented on issue #2468:
URL: https://github.com/apache/apisix/issues/2468#issuecomment-718736272


   We updated the 1.5 last_backup version of the dashboard. The bug of the above dashboard has been solved. 
   
   We solve the problem of retaining the original port by adding custom fields to the header through the proxy-rewrite plugin. At the same time, the back-end proxy configuration needs to be adapted, but this adjustment is universal, will not affect existing business, and will not increase maintenance. 
   
   Combined with the use of dashboard, it is really much easier to control the service. 
   
   The problem has been solved. thanks for your support for my 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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] membphis commented on issue #2468: request help: The problem of rewriting HTTP request header ‘Host’

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #2468:
URL: https://github.com/apache/apisix/issues/2468#issuecomment-718757085


   so we can close this issue, all right? @lizeming 


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] lizeming commented on issue #2468: request help: The problem of rewriting HTTP request header ‘Host’

Posted by GitBox <gi...@apache.org>.
lizeming commented on issue #2468:
URL: https://github.com/apache/apisix/issues/2468#issuecomment-715277084


   > please update your apisix to master branch or 2.0 version
   
   Okay, we will update to the master branch, thanks.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] membphis edited a comment on issue #2468: request help: The problem of rewriting HTTP request header ‘Host’

Posted by GitBox <gi...@apache.org>.
membphis edited a comment on issue #2468:
URL: https://github.com/apache/apisix/issues/2468#issuecomment-718003819


   > But there is a ‘host’ field in the header of the client request. The above 'proxy_set_header Host $http_host' is replaced by the client's ‘host’ so as to retain the originally requested port.
   
   can you show me an example of Nginx config about how to support this case via Nginx?
   I need it, for trying to find a better way to resolve this issue.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] membphis commented on issue #2468: request help: The problem of rewriting HTTP request header ‘Host’

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #2468:
URL: https://github.com/apache/apisix/issues/2468#issuecomment-717953015


   I think we should use `header_filter` phase to implement this feature.
   
   for nginx, I think it can not support this feature too, please confirm this.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] lizeming removed a comment on issue #2468: request help: The problem of rewriting HTTP request header ‘Host’

Posted by GitBox <gi...@apache.org>.
lizeming removed a comment on issue #2468:
URL: https://github.com/apache/apisix/issues/2468#issuecomment-713351657


   This is the proxy-rewrite plugin that we configured in APISIX. The Internet IP address and port of the redirect request are written into the http header "Host" field, and the service is called back to the client according to the http header "Host" field. Before using nginx, it can be done by proxy_set_header host $http_host, but in APISIX, proxy-rewrite needs to be fixed, which is not very convenient, and this rewriting is also invalid. http header "Host" field is always without a port. I have seen that the nginx configuration of APISIX is useful to cover the "Host" field by $host, but I don't know whether $host no longer has the original port.
   
   APISIX proxy-rewrite configuration
   ![Snipaste_2020-10-21_14-03-06](https://user-images.githubusercontent.com/897138/96682433-646afa80-13ab-11eb-9f4e-ad0601ca567e.jpg)
   ![Snipaste_2020-10-21_14-03-36](https://user-images.githubusercontent.com/897138/96682439-6765eb00-13ab-11eb-8138-26d99702ede1.jpg)
   ![Snipaste_2020-10-21_14-06-06](https://user-images.githubusercontent.com/897138/96682444-6a60db80-13ab-11eb-8dc9-6ae1d847c624.jpg)
   
   Header information requested by the client
   ![Snipaste_2020-10-21_14-01-42](https://user-images.githubusercontent.com/897138/96682484-751b7080-13ab-11eb-98b7-ab61ba212d17.jpg)
   
   The 'Host' field information sent to the backend via APISIX
   ![Snipaste_2020-10-21_13-56-59](https://user-images.githubusercontent.com/897138/96682517-82d0f600-13ab-11eb-9517-d73169e148b7.jpg)
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] lizeming removed a comment on issue #2468: request help: The problem of rewriting HTTP request header ‘Host’

Posted by GitBox <gi...@apache.org>.
lizeming removed a comment on issue #2468:
URL: https://github.com/apache/apisix/issues/2468#issuecomment-713353153


   > can you provide a real example of your case? we need to confirm it ^_^
   
   This is the proxy-rewrite plugin that we configured in APISIX. The Internet IP address and port of the redirect request are written into the http header "Host" field, and the service is called back to the client according to the http header "Host" field. Before using nginx, it can be done by proxy_set_header host $http_host, but in APISIX, proxy-rewrite needs to be fixed, which is not very convenient, and this rewriting is also invalid. http header "Host" field is always without a port. I have seen that the nginx configuration of APISIX is useful to cover the "Host" field by $host, but I don't know whether $host no longer has the original port.
   
   APISIX proxy-rewrite configuration
   ![Snipaste_2020-10-21_14-03-06](https://user-images.githubusercontent.com/897138/96683895-56b67480-13ad-11eb-862e-13edefccaed8.jpg)
   ![Snipaste_2020-10-21_14-03-36](https://user-images.githubusercontent.com/897138/96683909-5ae29200-13ad-11eb-8c83-7252249ddf13.jpg)
   ![Snipaste_2020-10-21_14-06-06](https://user-images.githubusercontent.com/897138/96683915-5f0eaf80-13ad-11eb-9654-1d554b676f32.jpg)
   
   Header information requested by the client
   ![Snipaste_2020-10-21_14-01-42](https://user-images.githubusercontent.com/897138/96683990-777eca00-13ad-11eb-979f-481357b4c635.jpg)
   
   The 'Host' field information sent to the backend via APISIX
   ![Snipaste_2020-10-21_13-56-59](https://user-images.githubusercontent.com/897138/96683960-6fbf2580-13ad-11eb-8368-b599149d7b8f.jpg)
   
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] lizeming commented on issue #2468: request help: The problem of rewriting HTTP request header ‘Host’

Posted by GitBox <gi...@apache.org>.
lizeming commented on issue #2468:
URL: https://github.com/apache/apisix/issues/2468#issuecomment-717923773


     The problem of upgrading to the master branch still exists. Maybe my description is not clear enough, this is our test information under the master branch:
     Our scenario is: the Internet initiates a request to 10.xxx.xxx.199:9080, and the APISIX access request is transferred to the back-end service. The back-end service will splice the new address according to the Host field of the HTTP header to the requesting client.
     In Nginx, we use 'proxy_set_header Host $http_host' to replace the Host field, because we need to reserve port 9080, but it cannot be implemented in APISIX. The back-end service always returns the Host field with the original request port removed. See the example for details.
   
   ![Snipaste_2020-10-28_21-08-33](https://user-images.githubusercontent.com/897138/97439939-c60a0680-1961-11eb-891d-c74bd62f0679.jpg)
   
     We tried to rewrite the Host field through the proxy-rewrite plugin.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] lizeming commented on issue #2468: request help: The problem of rewriting HTTP request header ‘Host’

Posted by GitBox <gi...@apache.org>.
lizeming commented on issue #2468:
URL: https://github.com/apache/apisix/issues/2468#issuecomment-718328570


   This is one of the business request chains. 
   
   This business has been around for a long time. 
   
   Request chain: client -> internet address(2xx.xxx.xxx.xx9:8096) -> pre-agent(172.xx.xxx.135:9080) -> business-agent(10.xx.xx.31:8096) -> business service(10.xx.xx.45)
   
   The following is a summary of the main configuration of the business chain:
   
   pre-agent(172.xx.xxx.135):
   ```
   http {
       server_tokens  off;
       include        mime.types;
       default_type   application/octet-stream;
       proxy_redirect off;
       server {
           listen 9080;
           location / {
               proxy_set_header Host $http_host;
               proxy_pass http://10.xx.xx.31:8096;
           }
       }
   }
   ```
   
   business-agent(10.xx.xx.31):
   ```
   http {
       server_tokens  off;
       include        mime.types;
       default_type   application/octet-stream;
       proxy_redirect off;
   
       server {
           listen 8096;
           location / {
               proxy_set_header Host $http_host;
               proxy_pass http://10.xx.xx.45:8080;
           }
       }
   }
   ```
   
   Request example:
   ```
   $ curl -v http://2xx.xxx.xxx.xx9:8096/crxxxxxxor/
   *   Trying 2xx.xxx.xxx.xx9:8096...
   * TCP_NODELAY set
   * Connected to 2xx.xxx.xxx.xx9 (2xx.xxx.xxx.xx9) port 8096 (#0)
   > GET /crxxxxxxor/ HTTP/1.1
   > Host: 2xx.xxx.xxx.xx9:8096
   > User-Agent: curl/7.68.0
   > Accept: */*
   >
   * Mark bundle as not supporting multiuse
   < HTTP/1.1 302 Found
   < connection: close
   < Content-Type: text/html;charset=utf-8
   < Content-Length: 0
   < Server: Openresty
   < Date: Thu, 29 Oct 2020 02:45:41 GMT
   < Set-Cookie: JSESSIONID=4664rfv5A55tgb11B6yhn67uj3; Path=/crxxxxxxor; HttpOnly
   < Location: http://2xx.xxx.xxx.xx9:8096/crxxxxxxor//login/loginManage/toLogin
   <
   * Closing connection 0
   ```


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] lizeming commented on issue #2468: request help: The problem of rewriting HTTP request header ‘Host’

Posted by GitBox <gi...@apache.org>.
lizeming commented on issue #2468:
URL: https://github.com/apache/apisix/issues/2468#issuecomment-717991320


   Yes. Nginx also does not reserve the port number in the internal ‘host’ field.
   
   But there is a ‘host’ field in the header of the client request. The above 'proxy_set_header Host $http_host' is replaced by the client's ‘host’ so as to retain the original requested port.
   
   For such scenarios, is it possible to provide apisix to modify the nginx configuration template to adapt to more use environments?


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] membphis commented on issue #2468: request help: The problem of rewriting HTTP request header ‘Host’

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #2468:
URL: https://github.com/apache/apisix/issues/2468#issuecomment-718003819


   > But there is a ‘host’ field in the header of the client request. The above 'proxy_set_header Host $http_host' is replaced by the client's ‘host’ so as to retain the original requested port.
   
   can you show me an example of Nginx config about how to support this case via Nginx?
   I will try to find a better to resolve this issue.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] lizeming commented on issue #2468: request help: The problem of rewriting HTTP request header ‘Host’

Posted by GitBox <gi...@apache.org>.
lizeming commented on issue #2468:
URL: https://github.com/apache/apisix/issues/2468#issuecomment-713353153


   > can you provide a real example of your case? we need to confirm it ^_^
   
   This is the proxy-rewrite plugin that we configured in APISIX. The Internet IP address and port of the redirect request are written into the http header "Host" field, and the service is called back to the client according to the http header "Host" field. Before using nginx, it can be done by proxy_set_header host $http_host, but in APISIX, proxy-rewrite needs to be fixed, which is not very convenient, and this rewriting is also invalid. http header "Host" field is always without a port. I have seen that the nginx configuration of APISIX is useful to cover the "Host" field by $host, but I don't know whether $host no longer has the original port.
   
   APISIX proxy-rewrite configuration
   ![Snipaste_2020-10-21_14-03-06](https://user-images.githubusercontent.com/897138/96683895-56b67480-13ad-11eb-862e-13edefccaed8.jpg)
   ![Snipaste_2020-10-21_14-03-36](https://user-images.githubusercontent.com/897138/96683909-5ae29200-13ad-11eb-8c83-7252249ddf13.jpg)
   ![Snipaste_2020-10-21_14-06-06](https://user-images.githubusercontent.com/897138/96683915-5f0eaf80-13ad-11eb-9654-1d554b676f32.jpg)
   
   Header information requested by the client
   ![Snipaste_2020-10-21_14-01-42](https://user-images.githubusercontent.com/897138/96683990-777eca00-13ad-11eb-979f-481357b4c635.jpg)
   
   The 'Host' field information sent to the backend via APISIX
   ![Snipaste_2020-10-21_13-56-59](https://user-images.githubusercontent.com/897138/96683960-6fbf2580-13ad-11eb-8368-b599149d7b8f.jpg)
   
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] lizeming commented on issue #2468: request help: The problem of rewriting HTTP request header ‘Host’

Posted by GitBox <gi...@apache.org>.
lizeming commented on issue #2468:
URL: https://github.com/apache/apisix/issues/2468#issuecomment-713374771


   > > can you provide a real example of your case? we need to confirm it ^_^
   > 
   > This is the proxy-rewrite plugin that we configured in APISIX. The Internet IP address and port of the redirect request are written into the http header "Host" field, and the service is called back to the client according to the http header "Host" field. Before using nginx, it can be done by proxy_set_header host $http_host, but in APISIX, proxy-rewrite needs to be fixed, which is not very convenient, and this rewriting is also invalid. http header "Host" field is always without a port. I have seen that the nginx configuration of APISIX is useful to cover the "Host" field by $host, but I don't know whether $host no longer has the original port.
   > 
   > APISIX proxy-rewrite configuration
   > ![Snipaste_2020-10-21_14-03-06](https://user-images.githubusercontent.com/897138/96683895-56b67480-13ad-11eb-862e-13edefccaed8.jpg)
   > ![Snipaste_2020-10-21_14-03-36](https://user-images.githubusercontent.com/897138/96683909-5ae29200-13ad-11eb-8c83-7252249ddf13.jpg)
   > ![Snipaste_2020-10-21_14-06-06](https://user-images.githubusercontent.com/897138/96683915-5f0eaf80-13ad-11eb-9654-1d554b676f32.jpg)
   > 
   > Header information requested by the client
   > ![Snipaste_2020-10-21_14-01-42](https://user-images.githubusercontent.com/897138/96683990-777eca00-13ad-11eb-979f-481357b4c635.jpg)
   > 
   > The 'Host' field information sent to the backend via APISIX
   > ![Snipaste_2020-10-21_13-56-59](https://user-images.githubusercontent.com/897138/96683960-6fbf2580-13ad-11eb-8368-b599149d7b8f.jpg)
   
   Most of the content is blocked due to the sensitive information involved in the project.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] lizeming commented on issue #2468: request help: The problem of rewriting HTTP request header ‘Host’

Posted by GitBox <gi...@apache.org>.
lizeming commented on issue #2468:
URL: https://github.com/apache/apisix/issues/2468#issuecomment-718400583


   We tried the proxy-rewrite plugin to add custom header fields, and then overwrite them with custom fields in the business proxy. This is indeed feasible.
   
   But apisix-dashboard has bugs. The newly added proxy-rewrite item will disappear if it is opened again. If you continue to edit and save the original proxy-rewrite configuration, it will be overwritten and lost.
   
   Because we need a dashboard to improve the processing efficiency and experience of the service, we also use the native dashboard as much as possible to keep up with the development of apisix.
   
   I also tried the latest apisix-dashboard 2.0-rc version. The proxy-rewrite plug-in availability is lower than the previous 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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] membphis commented on issue #2468: request help: The problem of rewriting HTTP request header ‘Host’

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #2468:
URL: https://github.com/apache/apisix/issues/2468#issuecomment-712639245


   can you provide a real example of your case? we need to confirm it ^_^


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] lizeming commented on issue #2468: request help: The problem of rewriting HTTP request header ‘Host’

Posted by GitBox <gi...@apache.org>.
lizeming commented on issue #2468:
URL: https://github.com/apache/apisix/issues/2468#issuecomment-713351657


   This is the proxy-rewrite plugin that we configured in APISIX. The Internet IP address and port of the redirect request are written into the http header "Host" field, and the service is called back to the client according to the http header "Host" field. Before using nginx, it can be done by proxy_set_header host $http_host, but in APISIX, proxy-rewrite needs to be fixed, which is not very convenient, and this rewriting is also invalid. http header "Host" field is always without a port. I have seen that the nginx configuration of APISIX is useful to cover the "Host" field by $host, but I don't know whether $host no longer has the original port.
   
   APISIX proxy-rewrite configuration
   ![Snipaste_2020-10-21_14-03-06](https://user-images.githubusercontent.com/897138/96682433-646afa80-13ab-11eb-9f4e-ad0601ca567e.jpg)
   ![Snipaste_2020-10-21_14-03-36](https://user-images.githubusercontent.com/897138/96682439-6765eb00-13ab-11eb-8138-26d99702ede1.jpg)
   ![Snipaste_2020-10-21_14-06-06](https://user-images.githubusercontent.com/897138/96682444-6a60db80-13ab-11eb-8dc9-6ae1d847c624.jpg)
   
   Header information requested by the client
   ![Snipaste_2020-10-21_14-01-42](https://user-images.githubusercontent.com/897138/96682484-751b7080-13ab-11eb-98b7-ab61ba212d17.jpg)
   
   The 'Host' field information sent to the backend via APISIX
   ![Snipaste_2020-10-21_13-56-59](https://user-images.githubusercontent.com/897138/96682517-82d0f600-13ab-11eb-9517-d73169e148b7.jpg)
   


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [apisix] membphis commented on issue #2468: request help: The problem of rewriting HTTP request header ‘Host’

Posted by GitBox <gi...@apache.org>.
membphis commented on issue #2468:
URL: https://github.com/apache/apisix/issues/2468#issuecomment-715147148


   please update your apisix to master branch or 2.0 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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org