简体   繁体   English

Apache反向代理问题

[英]Apache reverse proxy issues

I have an apache server and transmission-daemon running together. 我有一个apache服务器和传输守护程序一起运行。 Only ports 80 and 443 are open, I want to be able to access transmission's web interface from " https://address.net/transmission " instead of "localhost:9091" 仅开放了端口80和443,我希望能够从“ https://address.net/transmission ”而不是“ localhost:9091”访问传输的Web界面

I followed several guides but I can't make it work (ERR_CONNECTION_REFUSED or a 502), here's my last configuration. 我遵循了一些指南,但无法使其正常运行(ERR_CONNECTION_REFUSED或502),这是我的最后一个配置。 Thank you. 谢谢。

apache2.conf: apache2.conf:

Mutex file:${APACHE_LOCK_DIR} default
PidFile ${APACHE_PID_FILE}
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 5
User ${APACHE_RUN_USER}
Group ${APACHE_RUN_GROUP}
HostnameLookups Off
ErrorLog ${APACHE_LOG_DIR}/error.log
LogLevel warn

IncludeOptional mods-enabled/*.load
IncludeOptional mods-enabled/*.conf

Include ports.conf

<Directory /path/apache>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>


<Directory /path/apache/private>
        AuthType Basic
        AuthName "Restricted Content"
        AuthUserFile /path/.htpasswd
        Require valid-user
</Directory>

AccessFileName .htaccess
<FilesMatch "^\.ht">
    Require all denied
</FilesMatch>

IncludeOptional conf-enabled/*.conf
IncludeOptional sites-enabled/*.conf

ports.conf: ports.conf:

Listen 80
Listen 443

proxy.conf: proxy.conf:

<IfModule mod_proxy.c>
    ProxyRequests Off
    ProxyPreserveHost On
    <Proxy *>
        AddDefaultCharset off
        Order deny,allow
            Allow from all
    </Proxy>

        ProxyPass /transmission https://localhost:9091
        ProxyPassReverse /transmission https://localhost:9091

    ProxyVia On

</IfModule>

/sites-enabled/000-default.conf: /sites-enabled/000-default.conf:

<VirtualHost *:80>
    ServerName address.net

    DocumentRoot /path/apache

    ErrorLog ${APACHE_LOG_DIR}/error.log
    CustomLog ${APACHE_LOG_DIR}/access.log combined


        Redirect permanent / https://address.net/

</VirtualHost>

/sites-enabled/default-ssl.conf: /sites-enabled/default-ssl.conf:

<IfModule mod_ssl.c>
    <VirtualHost _default_:443>

        ServerName address.net
        DocumentRoot /path/apache


        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined


        SSLEngine on

        SSLCertificateFile  /stuff.pem
        SSLCertificateKeyFile /morestuff.pem


        SSLProxyEngine on

        <FilesMatch "\.(cgi|shtml|phtml|php)$">
                SSLOptions +StdEnvVars
        </FilesMatch>
        <Directory /usr/lib/cgi-bin>
                SSLOptions +StdEnvVars
        </Directory>

        BrowserMatch "MSIE [2-6]" \
                nokeepalive ssl-unclean-shutdown \
                downgrade-1.0 force-response-1.0
        BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown

    </VirtualHost>
</IfModule>

Maybe 也许

    ProxyPass /transmission https://localhost:9091
    ProxyPassReverse /transmission https://localhost:9091

should be: 应该:

    ProxyPass /transmission http://localhost:9091
    ProxyPassReverse /transmission http://localhost:9091

Setup which work for me (Debian jessie + apache2). 设置对我有用的(Debian jessie + apache2)。 I face problem connecting to webgui after permanent redirection to 443 using letsencrypt (SSL/TLS). 使用letencrypt(SSL / TLS)永久重定向到443后,我在连接到webgui时遇到问题。 First I need to enable proxy modules in Apache: 首先,我需要在Apache中启用代理模块:

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo systemctl restart apache2

Then I have to edit /etc/apache2/mods-available/proxy.conf file. 然后,我必须编辑/etc/apache2/mods-available/proxy.conf文件。 But before that I backup proxy.conf file like so: 但在此之前,我像这样备份proxy.conf文件:

cd /etc/apache2/mods-available
sudo mv proxy.conf proxy.conf.default

Now I create a new file called proxy.conf with following lines to it: 现在,我创建一个名为proxy.conf的新文件,其中包含以下几行:

<ifmodule mod_proxy.c>
  #turning ProxyRequests on and allowing proxying from all may allow
  #spammers to use your proxy to send email.

  ProxyRequests Off
  <proxy *>
    AddDefaultCharset off
    Order Allow,Deny
    Allow from all
  </proxy>

  ProxyPass /transmission http://localhost:9091/transmission
  ProxyPassReverse /transmission http://localhost:9091/transmission
  # Line below is optional
  Redirect permanent /transmission https://myserver.com/transmission/web/

  # Enable/disable the handling of HTTP/1.1 "Via:" headers.
  # ("Full" adds the server version; "Block" removes all outgoing Via: headers)
  # Set to one of: Off | On | Full | Block

  ProxyVia On
</ifmodule>

The ProxyPass and ReverseProxyPass lines create an Transmission Apache proxy (actually a reverse proxy). ProxyPass和ReverseProxyPass行创建了传输Apache代理(实际上是反向代理)。 The redirect statement (optional) permanently redirects http connections to https connections for security. 重定向语句(可选)将http连接永久重定向到https连接,以确保安全。 Restart apache: 重新启动Apache:

sudo systemctl restart apache2

Now you should be able to access transmission web interface using 现在您应该可以使用以下方式访问传输Web界面

https://myserver.com/transmission https://myserver.com/transmission

I case of 409 conflict. 我遇上409冲突。 Try 尝试

https://myserver.com/transmission/web/ https://myserver.com/transmission/web/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM