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

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.net resolves:
    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 A record for gogs points to the correct IP.
    • Flush local DNS caches:
      • Windows: ipconfig /flushdns
      • Mac/Linux: sudo systemd-resolve --flush-caches
    • Note: DNS changes can take up to 48 hours to propagate (depending on your TTL setting), but most providers refresh within 1-2 hours.

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.conf or /etc/httpd/conf.d/
  • 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:3000 with 127.0.0.1:3000—using the loopback address avoids relying on local DNS for your main domain, which can introduce unexpected issues.
  • Add ProxyRequests Off to 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
  • 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
      

5. Clear Browser & Intermediate Caches

  • Try accessing gogs.example.net in 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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.29 07:03:41