Apache 2.4 ProxyPass 到 url 导致 Diaspora 和 Mastodon 出现 403 和 502 错误

Apache 2.4 ProxyPass 到 url 导致 Diaspora 和 Mastodon 出现 403 和 502 错误

我试图在我的服务器上运行 Diaspora 和 Mastodon(这个想法很疯狂,对吧?),Apache 的 ProxyPass 无法在本地主机端口 3000(Diaspora)和 4000(Mastodon)上运行。我得到了 403https://diaspora.thechatpit.comhttps://mastodon.thechatpit.com-- 两者都有不同的用户,但我将这两个用户归入 Apache 所用用户的同一组中,并且权限已扩展,以便根据用户权限为该组的文件和目录提供相同的权限。我目前唯一能想到的办法就是将所有内容的权限修改为 777,但这永远不是正确的做法。

我将为每个配置文件添加编辑过的配置文件,从 Diaspora 开始:

# Diaspora config file for Apache

<VirtualHost *:80>
  ServerName diaspora.thechatpit.com
  RedirectPermanent / https://diaspora.thechatpit.com/
</VirtualHost>

<VirtualHost *:443>
  ServerName diaspora.thechatpit.com
  DocumentRoot "/usr/share/webapps/diaspora/public"

  SSLEngine on
  SSLCertificateFile <cert>
  SSLCertificateKeyFile <key>

  RewriteEngine on
  RewriteCond %{HTTP_HOST} !^diaspora\.thechatpit\.com [NC]
  RewriteRule ^/(.*)$ https://diaspora\.thechatpit\.com/$1 [L,R,QSA]

  # For Camo support
  RewriteRule ^/camo/(.*)$ balancer://camo/$1 [P,QSA,L]
 
  RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
  RewriteRule ^/(.*)$ balancer://upstream%{REQUEST_URI} [P,QSA,L]

  <Proxy balancer://upstream>
    BalancerMember http://localhost:3000
    BalancerMember http://localhost:8081
  </Proxy>

  ProxyRequests on
  ProxyVia on  
  ProxyPreserveHost on
  RequestHeader set X_FORWARDED_PROTO https

  <Proxy *>
    Require all granted
  </Proxy>

  <Directory "/usr/share/webapps/diaspora/public">
    Options -MultiViews
    Require all granted
  </Directory>

  <Location "/usr/share/webapps/diaspora/public">
    ProxyPass "https://localhost:3000"
    ProxyPassReverse "https://localhost:3000"
  </Location>

</VirtualHost>

...还有 Mastodon 的:

# Mastodon for Apache config file

<VirtualHost *:80>
  ServerName mastodon.thechatpit.com
  
  RedirectPermanent / https://mastodon.thechatpit.com/
</VirtualHost>

<VirtualHost *:443>
  ServerName mastodon.thechatpit.com
  DocumentRoot /var/lib/mastodon/public

  SSLEngine on
  SSLCertificateFile <cert>
  SSLCertificateKeyFile <key>

  RewriteEngine On
  RewriteCond %{HTTP_HOST} !^mastodon\.thechatpit\.com [NC]
  RewriteRule ^/(.*)$ https://mastodon\.thechatpit\.com/$1 [L,R,QSA]

  ProxyRequests on
  ProxyVia on
  ProxyPreserveHost on
  RequestHeader set X_FORWARDED_PROTO https

  <Proxy balancer://upstream>
    BalancerMember https://localhost:4000
  </Proxy>

  <Proxy *>
    Require all granted
  </Proxy>

  <Directory /var/lib/mastodon/public>
    Options -MultiViews
    Require all granted
  </Directory>

  <Location /var/lib/mastodon/public>
    ProxyPass "https://localhost:4000"
    ProxyPassReverse "https://localhost:4000"
  </Location>
</VirtualHost>

代理可能很简单,但我已经为此绞尽脑汁一整天,准备寻求帮助

相关内容