Apache2反向代理Odoo 11失败:域名无法跳转问题排查
Let’s break down the most likely issues here—reverse proxy setups often have small, easy-to-miss details that block things from working. Here’s what to check step by step:
Did you enable your site configuration?
You’ve created the.conffile insites-available, but Apache won’t use it until you explicitly enable it. Run this command first:sudo a2ensite your-config-filename.conf
Then restart Apache to apply changes:sudo systemctl restart apache2(orsudo service apache2 restartdepending on your Linux distro).Add
ProxyPassReverseto your VirtualHost
Your current config only includesProxyPass, but you needProxyPassReverseto rewrite response headers from the backend server. Without this, things like redirects or asset URLs might point directly to35.134.151.156:8069instead of your domain, breaking functionality. Update your config to:<VirtualHost *:80> ServerName erp.abclabs.com ProxyPass / http://35.134.151.156:8069/ ProxyPassReverse / http://35.134.151.156:8069/ </VirtualHost>Restart Apache after making this change.
Check Apache’s error logs for direct clues
The fastest way to diagnose issues is to watch the error log while testing access. Open a terminal and run:tail -f /var/log/apache2/error.log
Then try accessingerp.abclabs.comin your browser. You’ll see real-time errors—like permission issues, module loading failures, or backend connection problems—that will point you straight to the root cause.Verify the backend server is reachable from your Apache host
If Apache can’t connect to35.134.151.156:8069, the proxy won’t work. On the server running Apache, run:curl http://35.134.151.156:8069
If this returns an error, check:- The backend server’s firewall/security group allows incoming traffic on port 8069 from your Apache server’s IP.
- The backend service (I’m guessing Odoo, since it uses port 8069) is running and listening on
0.0.0.0(not just localhost).
Flush DNS cache and confirm hosts file entries
Even if you updated/etc/hosts, your local machine might still use cached DNS records. Flush the cache:- Linux:
sudo systemd-resolve --flush-caches - macOS:
sudo dscacheutil -flushcache - Windows:
ipconfig /flushdns
Also double-check your/etc/hostsentry for typos—it should be exactly:35.134.151.156 erp.abclabs.com
- Linux:
Check for VirtualHost conflicts
Make sure your custom VirtualHost is being prioritized over the default one. Run:sudo apache2ctl -S
This lists all enabled VirtualHosts and their matching order. Look forerp.abclabs.comin the output—if it’s missing, your site isn’t enabled. If it’s listed after the default000-default.conf, you might need to rename your config file to start with a lower letter (Apache sorts them alphabetically) to give it higher priority.Confirm proxy modules are actually loaded
Even if you rana2enmod proxy proxy_http, double-check with:apache2ctl -M | grep proxy
You should seeproxy_moduleandproxy_http_modulelisted asshared. If not, re-enable them and restart Apache.
内容的提问来源于stack exchange,提问作者Megha Sirisilla

