Introduction to Http Proxy Case

Introduction to Http Proxy Case

HTTP Proxy

The HTTP Proxy case demonstrates Pixiu’s ability to receive external HTTP requests and forward them to the underlying HTTP Server.

img

For the case code, please refer to /samples/http/simple. The directory structure and purpose in the case are as follows:

  1. - pixiu # Pixiu configuration file
  2. - server # http server
  3. - test # client or unit test

Let’s take a closer look at the specific configuration file for pixiu.

  1. static_resources:
  2. listeners:
  3. - name: "net/http"
  4. protocol_type: "HTTP" # Use HTTP Listener
  5. address:
  6. socket_address:
  7. address: "0.0.0.0" # Set the listening address to 0.0.0.0
  8. port: 8888 # Set port to 8888
  9. filter_chains:
  10. filters:
  11. - name: dgp.filter.httpconnectionmanager # Set NetworkFilter to httpconnectionmanager
  12. config:
  13. route_config:
  14. routes:
  15. - match:
  16. prefix: "/user" # Set routing rules to forward requests with /user prefix to the cluster named user
  17. route:
  18. cluster: "user"
  19. cluster_not_found_response_code: 505
  20. http_filters:
  21. - name: dgp.filter.http.httpproxy # Use dgp.filter.http.httpproxy for forwarding
  22. config:
  23. clusters:
  24. - name: "user" # Configure a cluster named user with one instance at address 127.0.0.1:1314
  25. lb_policy: "random"
  26. endpoints:
  27. - id: 1
  28. socket_address:
  29. address: 127.0.0.1
  30. port: 1314

First, start the Http Server in the Server folder and then use the following command to start Pixiu. Finally, execute the unit tests in the test folder. Note that -c should be followed by the absolute path of the local configuration file.

  1. pixiu gateway start -c /pixiu/conf.yaml

Feedback

Was this page helpful?

Yes No

Last modified September 30, 2024: Update & Translate Overview Docs (#3040) (d37ebceaea7)