如何配置Apache Httpd处理Safari推送通知的Agent请求
Hey there! I’ve tackled this exact migration before when switching from Nginx to Apache for Safari push notifications, so let me break down how to translate that Nginx config into Apache-friendly syntax.
First, make sure you have these Apache modules enabled—they’re required for handling CORS headers and forwarding requests to your PHP-FPM backend:
mod_proxymod_proxy_fcgimod_headers
On most Debian/Ubuntu systems, you can enable them with these commands:
a2enmod proxy proxy_fcgi headers systemctl restart apache2
1. Safari Push Package Request Configuration
This maps directly to your Nginx /push/v2/pushPackages/web.com.domain.appname location block. Add this to your Apache virtual host config:
<Location "/push/v2/pushPackages/web.com.domain.appname"> # Allow cross-origin requests (matches Nginx's add_header) Header set Access-Control-Allow-Origin "*" # Allow all clients to access this endpoint (matches Nginx's allow all) Require all granted # Forward request to PHP-FPM backend, specifying the script file (combines fastcgi_pass and SCRIPT_FILENAME) ProxyPass "fcgi://127.0.0.1:9000/var/www/safari.push/index.php" ProxyPassReverse "fcgi://127.0.0.1:9000/var/www/safari.push/index.php" </Location>
2. Safari Push Log Configuration
Similarly, here’s the Apache equivalent for the Nginx /push/v2/log block:
<Location "/push/v2/log"> Header set Access-Control-Allow-Origin "*" Require all granted ProxyPass "fcgi://127.0.0.1:9000/var/www/safari.push/log.php" ProxyPassReverse "fcgi://127.0.0.1:9000/var/www/safari.push/log.php" </Location>
Quick Notes
- If you’re using an older Apache setup with
mod_fastcgiinstead ofmod_proxy_fcgi, the syntax will differ slightly—let me know if you need that version. - Double-check the path to your PHP files (
/var/www/safari.push/...) matches your actual server setup. - After updating the config, restart Apache to apply changes.
If you hit any snags with module loading, permission issues, or path mismatches, feel free to share more details—I’m happy to help troubleshoot further!
内容的提问来源于stack exchange,提问作者Kirill Barsukov

