首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Apache安装[不重复]

Apache安装[不重复]
EN

Server Fault用户
提问于 2021-07-19 22:09:22
回答 1查看 85关注 0票数 0

我试图在我的ubuntu服务器20.04上安装ssl证书。

我已经下载了ssl文件,并将它们放入/home/ubuntu (一旦运行就会改变):

  • api_limitlesssoft_com_key.txt
  • api.limitlesssoft.com.p7b
  • api.limitlesssoft.com.crt
  • api.limitlesssoft.com.ca-bundle

现在我所做的是编辑虚拟主机文件,如下所示:

代码语言:javascript
运行
复制
LoadModule ssl_module modules/mod_ssl.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so


        ServerName api.limitlesssoft.com
        ServerAdmin aleksa@limitlesssoft.com

        ProxyPreserveHost On
        ProxyPass / http://127.0.0.1:5000/
        ProxyPassReverse / http://127.0.0.1:5000/

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



        ServerName api.limitlesssoft.com
        ServerAdmin aleksa@limitlesssoft.com

        ProxyPreserveHost On
        ProxyPass / http://127.0.0.1:5000/
        ProxyPassReverse / http://127.0.0.1:5000/

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

        SSLEngine on
        SSLCertificateFile /home/ubuntu/api.limitlesssoft.com.crt
        SSLCertificateKeyFile /home/ubuntu/api_limitlesssoft_com_key.txt
        SSLCertificateChainFile /home/ubuntu/api.limitlesssoft.com.ca-bundle

由于某种原因,只有http 1才能工作。

a2enmod ssl返回它已经在运行的消息,我已经运行了sudo ufw 443,并且启用了

代码语言:javascript
运行
复制
ubuntu@ubuntu:/var/log/apache2$ telnet localhost 443
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
代码语言:javascript
运行
复制
ubuntu@ubuntu:/var/log/apache2$ sudo netstat -peanut | grep ':80'
tcp6       0      0 :::80                   :::*                    LISTEN      0          46821      3493/apache2   
ubuntu@ubuntu:/var/log/apache2$ sudo netstat -peanut | grep ':443'
tcp6       0      0 :::443                  :::*                    LISTEN      0          46825      3493/apache2   
tcp6       0      0 127.0.0.1:443           127.0.0.1:45968         TIME_WAIT   0          0          -  
代码语言:javascript
运行
复制
ubuntu@ubuntu:/var/log/apache2$ netstat -a -n
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 127.0.0.1:5000          0.0.0.0:*               LISTEN
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN
tcp        1      0 127.0.0.1:41170         127.0.0.1:5000          CLOSE_WAIT
tcp        0    192 192.168.1.109:22        192.168.1.2:61495       ESTABLISHED
tcp6       0      0 ::1:5000                :::*                    LISTEN
tcp6       0      0 :::80                   :::*                    LISTEN
tcp6       0      0 :::21                   :::*                    LISTEN
tcp6       0      0 :::22                   :::*                    LISTEN
tcp6       0      0 :::443                  :::*                    LISTEN
udp        0      0 127.0.0.53:53           0.0.0.0:*
udp        0      0 192.168.1.109:68        0.0.0.0:*
raw6       0      0 :::58                   :::*                    7
代码语言:javascript
运行
复制
ubuntu@ubuntu:~$ sudo ufw status
Status: active

To                         Action      From
--                         ------      ----
33380                      ALLOW       Anywhere
443                        ALLOW       Anywhere
22                         ALLOW       Anywhere
80                         ALLOW       Anywhere
33380 (v6)                 ALLOW       Anywhere (v6)
443 (v6)                   ALLOW       Anywhere (v6)
22 (v6)                    ALLOW       Anywhere (v6)
80 (v6)                    ALLOW       Anywhere (v6)

下面是我的应用程序启动(调试时它在https上工作)

代码语言:javascript
运行
复制
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.HttpOverrides;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace api.limitlesssoft.com
{
    public class Startup
    {
        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            services.Configure(options =>
            {
                options.ForwardedHeaders =
                    ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto;
            });
        }

        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseForwardedHeaders();

            app.UseHttpsRedirection();

            app.UseStaticFiles();

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
    }
}
EN

回答 1

Server Fault用户

发布于 2021-07-19 22:38:12

Apache上的连接拒绝HTTPS中找到解决方案,它被标记为-1点.问题是路线问题..。端口转发没有转发端口443,只有80个端口。这就是它不起作用的原因。

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

https://serverfault.com/questions/1070061

复制
相关文章

相似问题

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