中国站
帮助中心 > 安全 > 高防IP > 常见问题 > 高防IP回源字段参考

高防IP回源字段参考

回源服务器地址为IP格式

配置

获取请求头方法

以PHP为例。

  1. <?
  2. print_r($_SERVER);
  3. ?>

以SpringBoot(Java)为例。

  1. @RestController
  2. public class TestController {
  3. @GetMapping("/test")
  4. public String test(HttpServletRequest request) {
  5. Enumeration headerNames = request.getHeaderNames();
  6. while (headerNames.hasMoreElements()) {
  7. String headerName = headerNames.nextElement();
  8. String headerValue = request.getHeader(headerName);
  9. System.out.println(headerName + ":" + headerValue);
  10. }
  11. return "success";
  12. }
  13. }
  1. 源服务器未使用代理转发该端口的请求(如没有使用nginx转发端口请求)。
    http协议 请求的字段

    1. array(10) {
    2. ["request_method"]=>
    3. string(3) "GET"
    4. ["request_uri"]=>
    5. string(1) "/"
    6. ["path_info"]=>
    7. string(1) "/"
    8. ["request_time"]=>
    9. int(1613802357)
    10. ["request_time_float"]=>
    11. float(1613802357.2114)
    12. ["server_protocol"]=>
    13. string(8) "HTTP/1.1"
    14. ["server_port"]=>
    15. int(4501)
    16. ["remote_port"]=>
    17. int(31205)
    18. ["remote_addr"]=>
    19. string(14) "**购买的高防IP**"
    20. ["master_time"]=>
    21. int(1613802357)
    22. }

    header中的 字段

    1. array(11) {
    2. ["host"]=>
    3. string(21) "添加的域名"
    4. ["x-real-ip"]=>
    5. string(13) "真实的访客IP"
    6. ["x-forwarded-host"]=>
    7. string(15) "访问域名"
    8. ["x-forwarded-scheme"]=>
    9. string(4) "http"
    10. ["x-forwarded-for"]=>
    11. string(13) "真实的访客IP"
    12. ["user-agent"]=>
    13. string(115) "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36"
    14. ["connection"]=>
    15. string(10) "keep-alive"
    16. ["accept"]=>
    17. string(50) "image/avif,image/webp,image/apng,image/*,*/*;q=0.8"
    18. ["referer"]=>
    19. string(29) "..."
    20. ["accept-encoding"]=>
    21. string(13) "gzip, deflate"
    22. ["accept-language"]=>
    23. string(14) "zh-CN,zh;q=0.9"
    24. }
  2. 源服务器使用代理服务转发端口的请求(如使用nginx转发)。
    nginx 配置参考

    1. server {
    2. listen 8481;#如源机接收请求的端口设置为8481端口,而8481端口又转发请求
    3. server_name localhost;
    4. root /home/www/;
    5. index index.php;
    6. location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
    7. expires 100d;
    8. }
    9. location ~ .*\.(js|css)?$ {
    10. expires 30d;
    11. }
    12. location ~ \.php$ {
    13. fastcgi_pass 127.0.0.1:9000;
    14. fastcgi_index index.php;
    15. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    16. fastcgi_param PATH_INFO $fastcgi_path_info;
    17. fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
    18. include fastcgi_params;
    19. }
    20. }

    返回字段参考

    1. array
    2. {
    3. [USER] => www-data
    4. [HOME] => /home/www-data
    5. [HTTP_COOKIE] => yisu_sign_javascript=8bc2a608d434ebc5e6914faf090c4bda
    6. [HTTP_ACCEPT_LANGUAGE] => zh-CN,zh;q=0.9
    7. [HTTP_ACCEPT_ENCODING] => gzip, deflate
    8. [HTTP_REFERER] => ...
    9. [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
    10. [HTTP_UPGRADE_INSECURE_REQUESTS] => 1
    11. [HTTP_CACHE_CONTROL] => max-age=0
    12. [HTTP_CONNECTION] => keep-alive
    13. [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36
    14. [HTTP_X_FORWARDED_FOR] => 真实访客的IP
    15. [HTTP_X_FORWARDED_SCHEME] => http
    16. [HTTP_X_FORWARDED_HOST] => 访问的域名
    17. [HTTP_X_REAL_IP] => 真实访客IP
    18. [HTTP_HOST] => 添加的域名
    19. [REDIRECT_STATUS] => 200
    20. [SERVER_NAME] => localhost
    21. [SERVER_PORT] => 8481
    22. [SERVER_ADDR] => 源服务器地址
    23. [REMOTE_PORT] => 34338
    24. [REMOTE_ADDR] => 购买的高防IP
    25. [SERVER_SOFTWARE] => nginx/1.19.2
    26. [GATEWAY_INTERFACE] => CGI/1.1
    27. [REQUEST_SCHEME] => http
    28. [SERVER_PROTOCOL] => HTTP/1.0
    29. [DOCUMENT_ROOT] => /home/www
    30. [DOCUMENT_URI] => /index.php
    31. [REQUEST_URI] => /
    32. [SCRIPT_NAME] => /index.php
    33. [CONTENT_LENGTH] =>
    34. [CONTENT_TYPE] =>
    35. [REQUEST_METHOD] => GET
    36. [QUERY_STRING] =>
    37. [QY_DEBUG] => 1
    38. [QY_CONF] => dev
    39. [PATH_TRANSLATED] => /home/www
    40. [PATH_INFO] =>
    41. [SCRIPT_FILENAME] => /home/www/index.php
    42. [FCGI_ROLE] => RESPONDER
    43. [PHP_SELF] => /index.php
    44. [REQUEST_TIME_FLOAT] => 1613802985.2393
    45. [REQUEST_TIME] => 1613802985
    46. }

回源服务器地址为域名格式

配置

  • 源服务器使用代理服务转发端口的请求(如使用nginx 转发)
    返回字段参考
    1. Array
    2. {
    3. [USER] => www-data
    4. [HOME] => /home/www-data
    5. [HTTP_COOKIE] => yisu_sign_javascript=8bc2a608d434ebc5e6914faf090c4bda
    6. [HTTP_ACCEPT_LANGUAGE] => zh-CN,zh;q=0.9
    7. [HTTP_ACCEPT_ENCODING] => gzip, deflate
    8. [HTTP_REFERER] => ...
    9. [HTTP_ACCEPT] => text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
    10. [HTTP_UPGRADE_INSECURE_REQUESTS] => 1
    11. [HTTP_CACHE_CONTROL] => max-age=0
    12. [HTTP_CONNECTION] => keep-alive
    13. [HTTP_USER_AGENT] => Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36
    14. [HTTP_X_FORWARDED_FOR] => 真实访客的IP
    15. [HTTP_X_FORWARDED_SCHEME] => http
    16. [HTTP_X_FORWARDED_HOST] => 访问的域名
    17. [HTTP_X_REAL_IP] => 真实访客IP
    18. [HTTP_HOST] => 是添加的域名,不是回源填写的域名
    19. [REDIRECT_STATUS] => 200
    20. [SERVER_NAME] => localhost
    21. [SERVER_PORT] => 8481
    22. [SERVER_ADDR] => 源服务器地址
    23. [REMOTE_PORT] => 34338
    24. [REMOTE_ADDR] => 购买的高防IP
    25. [SERVER_SOFTWARE] => nginx/1.19.2
    26. [GATEWAY_INTERFACE] => CGI/1.1
    27. [REQUEST_SCHEME] => http
    28. [SERVER_PROTOCOL] => HTTP/1.0
    29. [DOCUMENT_ROOT] => /home/www
    30. [DOCUMENT_URI] => /index.php
    31. [REQUEST_URI] => /
    32. [SCRIPT_NAME] => /index.php
    33. [CONTENT_LENGTH] =>
    34. [CONTENT_TYPE] =>
    35. [REQUEST_METHOD] => GET
    36. [QUERY_STRING] =>
    37. [QY_DEBUG] => 1
    38. [QY_CONF] => dev
    39. [PATH_TRANSLATED] => /home/www
    40. [PATH_INFO] =>
    41. [SCRIPT_FILENAME] => /home/www/index.php
    42. [FCGI_ROLE] => RESPONDER
    43. [PHP_SELF] => /index.php
    44. [REQUEST_TIME_FLOAT] => 1613802985.2393
    45. [REQUEST_TIME] => 1613802985
    46. }