首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用Apache和Raspberry Pi设置安全代理

问使用Apache和Raspberry Pi设置安全代理
EN

Stack Overflow用户
提问于 2018-04-19 22:52:15
回答 1查看 283关注 0票数 1

我正在尝试设置我自己的安全代理,以供我编写的Django Python脚本使用,该脚本依赖于安全代理来正确返回https请求。这是因为脚本是从美国主机服务器上运行的,我希望响应来自英国。

为了实现这一点并学习一些新的东西,我正在尝试配置一个运行在我的Raspberry Pi上的Apache服务器。(我预计不会有大量的流量!)

我已经成功地创建了SSL证书,并拥有正确的文件.pem、.csr (和.csr)。

我相信我已经将它们复制到了正确的位置: /etc/ssl/private和/etc/ssl/certs。我认为我现在遇到的唯一问题是apache配置。

目前,我正在尝试配置启用站点的/default-ssl.conf文件,如下所示:

代码语言:javascript
复制
    <IfModule mod_ssl.c>
    <VirtualHost _default_:443>
            ServerAdmin webmaster@localhost

            DocumentRoot /var/www/html

            # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
            # error, crit, alert, emerg.
            # It is also possible to configure the loglevel for particular
            # modules, e.g.
            #LogLevel info ssl:warn

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

            # For most configuration files from conf-available/, which are
            # enabled or disabled at a global level, it is possible to
            # include a line for only one particular virtual host. For example the
            # following line enables the CGI configuration for this host only
            # after it has been globally disabled with "a2disconf".
            #Include conf-available/serve-cgi-bin.conf

            #   SSL Engine Switch:
            #   Enable/Disable SSL for this virtual host.
            SSLEngine on

            #   A self-signed (snakeoil) certificate can be created by installing
            #   the ssl-cert package. See
            #   /usr/share/doc/apache2/README.Debian.gz for more info.
            #   If both key and certificate are stored in the same file, only the
            #   SSLCertificateFile directive is needed.
            #SSLCertificateFile     /etc/ssl/certs/ssl-cert-snakeoil.pem
            #SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key
            SSLCertificateFile /etc/ssl/certs/aa5758835031e4a3.crt
            SSLCertificateKeyFile /etc/ssl/private/<domainname>.key

我对服务器的设置非常陌生,我花了大量的时间在网上搜索和尝试许多不同的建议方法。我确信这是我忽略的非常简单的事情,但经验不足;我不能凭直觉解决这个问题。

感谢您的帮助和指点...

更新:

嘿,谢谢你的回复。

对http的响应: is

代码语言:javascript
复制
   * Rebuilt URL to: http://*.*.*/
    *   Trying 184.168.221.1...
    * TCP_NODELAY set
    * Connected to *.*.* port 80 (#0)
    > GET / HTTP/1.1
    > Host : *.*.*
    > User-Agent: curl/7.52.1
    > Accept: */*
    >
    < HTTP/1.1 302 Found
    < Connection: close
    < Pragma: no-cache
    < cache-control: no-cache
    < Location: /VZaKp/
    <
    * Curl_http_done: called premature == 0
    * Closing connection 0 

https是:

代码语言:javascript
复制
    * Rebuilt URL to: https://*.*.*/
    *   Trying 50.63.202.18...
    * TCP_NODELAY set
    * connect to 50.63.202.18 port 443 failed: Connection timed out
    * Failed to connect to *.*.* port 443: Connection timed out
    * Closing connection 0
    curl: (7) Failed to connect to *.*.* port 443: Connection timed out

更新23.04.2018:

谢谢。我相信我已经解决了听力问题,但现在遇到了一个新的问题!

尝试重新启动apache2服务时,出现以下错误:

代码语言:javascript
复制
     Apr 23 12:31:30 matthew-raspberry systemd[1]: Starting The Apache HTTP Server...
     Apr 23 12:31:31 matthew-raspberry apachectl[8341]: Action 'start' failed.
     Apr 23 12:31:31 matthew-raspberry apachectl[8341]: The Apache error log may have more information.
    Apr 23 12:31:31 matthew-raspberry systemd[1]: apache2.service: Control process exited, code=exited status=1
    Apr 23 12:31:31 matthew-raspberry systemd[1]: Failed to start The Apache HTTP Server.
    Apr 23 12:31:31 matthew-raspberry systemd[1]: apache2.service: Unit entered failed state.
    Apr 23 12:31:31 matthew-raspberry systemd[1]: apache2.service: Failed with result 'exit-code'.

我怀疑这可能与我的fqdn设置和/或证书有关。在将ServerName本地主机添加为全局名称时,我得到了这个错误。我添加这个是因为前面的错误消息是关于确定我的fqdn名称,这建议添加ServerName作为全局变量?

EN

回答 1

Stack Overflow用户

发布于 2018-04-22 21:40:14

端口443即使在基本TCP级别也是不可到达的。确保在Apache配置中包含以下内容:

代码语言:javascript
复制
Listen 443 https

配置更改后重新加载httpd。检查firewall-cmd --list-all-zones或iptables -S,查看是否允许连接到端口443。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49924088

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档