Apache服务器配置Gogs.io子域名访问问题求助
Troubleshooting Guide: Fixing gogs.example.net DNS & Reverse Proxy Issues
Let's walk through targeted steps to resolve this problem—since your setup worked before and broke after a subdomain tweak (even when reverted), the issue is likely tied to caching, misconfigured DNS, or an Apache configuration that didn't properly reload.
1. Verify DNS Resolution for gogs.example.net
The AT&T DNS error strongly suggests your subdomain isn't pointing to your server's public IP.
- Run these commands on your local machine and your server to check where
gogs.example.netresolves:nslookup gogs.example.net # OR dig gogs.example.net - Confirm the output shows your server's public IP. If not:
- Double-check your domain registrar's DNS records to ensure the
Arecord forgogspoints to the correct IP. - Flush local DNS caches:
- Windows:
ipconfig /flushdns - Mac/Linux:
sudo systemd-resolve --flush-caches
- Windows:
- Note: DNS changes can take up to 48 hours to propagate (depending on your TTL setting), but most providers refresh within 1-2 hours.
- Double-check your domain registrar's DNS records to ensure the
2. Ensure Apache Configuration is Active & Reloaded
It's easy to make a config change but forget to apply it, or have a hidden syntax error.
- First, confirm your virtual host file is enabled:
- Debian/Ubuntu: Run
sudo a2ensite your-gogs-config.conf(replace with your actual config filename) - RHEL/CentOS: Ensure your config is included in
/etc/httpd/conf/httpd.confor/etc/httpd/conf.d/
- Debian/Ubuntu: Run
- Reload Apache to apply changes (don't just restart—reload is gentler):
# Debian/Ubuntu sudo systemctl reload apache2 # RHEL/CentOS sudo systemctl reload httpd - Check Apache's error log for clues if the reload fails:
# Debian/Ubuntu cat /var/log/apache2/error.log # RHEL/CentOS cat /var/log/httpd/error_log
3. Optimize Your Reverse Proxy Configuration
Your current config is close, but we can make it more reliable:
- Replace
example.net:3000with127.0.0.1:3000—using the loopback address avoids relying on local DNS for your main domain, which can introduce unexpected issues. - Add
ProxyRequests Offto disable forward proxying (safer for reverse proxy setups).
Updated config:
<VirtualHost *:80> ServerName gogs.example.net ProxyPreserveHost On ProxyRequests Off ProxyPass / http://127.0.0.1:3000/ ProxyPassReverse / http://127.0.0.1:3000/ </VirtualHost>
After updating, reload Apache again and test locally on your server with:
curl http://gogs.example.net
If this returns Gogs' HTML content, the proxy itself is working.
4. Check Firewall & SELinux Restrictions
- Ensure port 80 is open on your server's firewall:
- UFW (Debian/Ubuntu):
sudo ufw allow 80/tcp - Firewalld (RHEL/CentOS):
sudo firewall-cmd --add-service=http --permanent && sudo firewall-cmd --reload
- UFW (Debian/Ubuntu):
- For RHEL/CentOS systems, SELinux might block Apache from connecting to the 3000 port:
- Test temporarily by disabling SELinux:
sudo setenforce 0 - If access works after this, set a permanent rule to allow Apache network connections:
sudo setsebool -P httpd_can_network_connect on
- Test temporarily by disabling SELinux:
5. Clear Browser & Intermediate Caches
- Try accessing
gogs.example.netin your browser's incognito/private mode to bypass cached DNS or page data. - If you're still seeing the AT&T error, your ISP might have cached the old DNS record. Wait a few hours, or contact your ISP to request a cache flush.
内容的提问来源于stack exchange,提问作者Gman0064
相关产品推荐
相关产品推荐

