You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Apache部分请求丢失Referer信息,请求排查服务器端原因

Hey Mike, let's break down your problem step by step based on what you've shared. It's totally valid to suspect server-side issues here—especially since you confirmed the Referer should exist during your real-time testing. Let's cover the likely culprits and how to investigate them:

1. First, rule out source website edge cases

While you mentioned multiple sources have issues, it's worth quickly eliminating these common scenarios:

  • Browser/extension privacy settings: Some browsers (in incognito mode) or ad-blocking extensions block Referer headers by default. But since you tested this yourself in real time, this probably doesn't apply to your specific missing logs.
  • noreferrer link attributes: If the source site's links use rel="noreferrer" or rel="noopener noreferrer", browsers won't send a Referer. Double-check the HTML of the links you tested to rule this out.

2. Server-side (Apache + Nginx Cache) investigation priorities

Since you're on Plesk with an Apache + Nginx reverse proxy/cache stack, most Referer loss issues here trace back to Nginx's proxy configuration or Apache's header handling.

2.1 Check Nginx's proxy header forwarding

Nginx acts as the front-end layer here, so it needs to explicitly pass the Referer header to Apache. If this is missing, Apache will never see the header:

  1. In Plesk, go to Domains > [Your Domain] > Apache & Nginx Settings
  2. Look in the Additional Nginx directives section for this line:
    proxy_set_header Referer $http_referer;
    
    If it's missing, add it and save the configuration. Then restart Nginx via Tools & Settings > Services Management.
  3. Also check Nginx's cache rules: Some cache configurations might ignore request headers like Referer, or serve cached responses without accounting for different Referer values. Ensure your cache setup doesn't strip or ignore this header.

2.2 Verify Apache's Referer handling

Apache itself could be modifying or stripping the Referer header via modules like mod_rewrite or mod_headers:

  1. In Plesk, go to Domains > [Your Domain] > Apache & Nginx Settings > Additional Apache directives
  2. Look for any rules that modify the Referer, such as:
    Header unset Referer
    # Or rewrite rules targeting the Referer
    RewriteCond %{HTTP_REFERER} ...
    RewriteRule ...
    
    If you find any, temporarily comment them out and test again to see if Referers start appearing in logs.
  3. Your log format already includes "%{Referer}i", so Apache is configured to log the header correctly—this means the issue is that the header never reaches Apache in the first place.

2.3 Test bypassing Nginx directly

To isolate whether the problem is Nginx or Apache:

  1. Find Apache's listening port (usually 8080 on Plesk setups)
  2. Use curl to send a request directly to Apache with a Referer header:
    curl -H "Referer: https://test-source.com" http://your-domain.com:8080/
    
  3. Check your Apache access logs. If the Referer shows up here, the problem is definitely in Nginx's proxy configuration. If it's still missing, you'll need to dig deeper into Apache's global settings.

3. Plesk-specific configuration gotchas

Plesk auto-generates configuration files, so make sure:

  • You're modifying domain-specific directives (not global ones) to avoid overwrites during Plesk updates.
  • After making changes, you restart both Apache and Nginx services—sometimes a single restart isn't enough.

4. Deep dive: Log Nginx's incoming requests

If you're still stuck, enable detailed logging in Nginx to confirm whether it even receives the Referer header:

  1. Add this log format to your domain's Additional Nginx directives:
    log_format full_requests '$remote_addr - $remote_user [$time_local] "$request" '
                            '$status $body_bytes_sent "$http_referer" "$http_user_agent"';
    access_log /var/log/nginx/your-domain-full.log full_requests;
    
  2. Restart Nginx, then replicate the issue.
  3. Check the new log file:
    • If Nginx shows the Referer but Apache doesn't: Nginx isn't forwarding the header correctly (go back to step 2.1).
    • If Nginx also shows "-" for Referer: The header is missing before it reaches your server—this could point to a CDN (if you use one) or network-level filtering, but since you tested in real time, this is less likely.

Final thought

Given your real-time testing confirms the Referer should exist, the most probable culprit is Nginx failing to forward the header to Apache. Start there, and work your way through the steps above—you'll likely find the fix quickly.

内容的提问来源于stack exchange,提问作者Mike

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.13 08:06:08