0

我有sudo docker run -d --restart unless-stopped -it -v $(pwd):/data -p 81:80 maptiler/tileserver-gl跑步。我可以访问http://mypage.com:81就好了。但是,我想访问https://mypage.com:81。我有一个有效的证书,但它无法使用https协议。下面是我的nginx.conf文件。

server {
        listen 80;
        listen [::]:80 default_server;
        listen       443 ssl http2 default_server;
        listen       [::]:443 ssl http2 default_server;
        server_name  mypage.com;
        root         /usr/share/nginx/html;

        ssl_certificate "/etc/pki/nginx/certs/mypage.com.crt";
        ssl_certificate_key "/etc/pki/nginx/certs/mypage.com.key";
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  10m;
        ssl_ciphers PROFILE=SYSTEM;
        ssl_prefer_server_ciphers on;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
                proxy_pass http://localhost:80;
                proxy_set_header X-Forwarded-Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header Host $http_host;

        }

4

1 回答 1

0

这里的解决方案是

server {
        listen 81 ssl;
        listen [::]:81 ssl;
        listen       443 ssl http2 default_server;
        listen       [::]:443 ssl http2 default_server;
        server_name  mypage.com;
        root         /usr/share/nginx/html;

        ssl_certificate "/etc/pki/nginx/certs/mypage.com.crt";
        ssl_certificate_key "/etc/pki/nginx/certs/mypage.com.key";
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  10m;
        ssl_ciphers PROFILE=SYSTEM;
        ssl_prefer_server_ciphers on;

        # Load configuration files for the default server block.
        include /etc/nginx/default.d/*.conf;

        location / {
                proxy_pass http://localhost:80;
                proxy_set_header X-Forwarded-Host $host;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header Host $http_host;

        }

观察端口 80 上的ssl

于 2021-05-26T17:49:36.153 回答