我试图在我的ubuntu服务器20.04上安装ssl证书。
我已经下载了ssl文件,并将它们放入/home/ubuntu (一旦运行就会改变):
现在我所做的是编辑虚拟主机文件,如下所示:
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,并且启用了
ubuntu@ubuntu:/var/log/apache2$ telnet localhost 443
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.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 - 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 :::* 7ubuntu@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上工作)
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();
});
}
}
}发布于 2021-07-19 22:38:12
在Apache上的连接拒绝HTTPS中找到解决方案,它被标记为-1点.问题是路线问题..。端口转发没有转发端口443,只有80个端口。这就是它不起作用的原因。
https://serverfault.com/questions/1070061
复制相似问题