大网数据广告活动
服务器运维问答

Can't access https despite port 443 is opened

· 52CE 我爱测

This is my first time setting up a server and I've just installed a SSL cert. I have also made some changes to the iptable to allow access to 443. Below is the output of iptables -L target prot opt source destination ACCEPT all -…

问题原文

原帖链接 · Gino · CC BY-SA 3.0

This is my first time setting up a server and I've just installed a SSL cert. I have also made some changes to the iptable to allow access to 443. Below is the output of iptables -L

target     prot opt source         destination
ACCEPT     all  --  anywhere       anywhere        state RELATED,ESTABLISHED
ACCEPT     tcp  --  anywhere       anywhere        state NEW tcp dpt:http
ACCEPT     icmp --  anywhere       anywhere
ACCEPT     all  --  anywhere       anywhere
ACCEPT     tcp  --  anywhere       anywhere        state NEW tcp dpt:ssh
ACCEPT     tcp  --  anywhere       anywhere        state NEW tcp dpt:smtp
ACCEPT     udp  --  anywhere       anywhere        state NEW udp dpt:smtp
ACCEPT     tcp  --  anywhere       anywhere        tcp dpt:urd
REJECT     all  --  anywhere       anywhere        reject-with icmp-host-prohibited
ACCEPT     tcp  --  anywhere       anywhere        state NEW tcp dpt:https

I also checked nmap by ssh'ing into the server and run nmap from the server itself.

Starting Nmap 5.51 ( http://nmap.org ) at 2016-04-15 15:31 SGT
Nmap scan report for <my.domain.ip>
Host is up (0.0000050s latency).
Not shown: 994 closed ports
PORT     STATE SERVICE
22/tcp   open  ssh
25/tcp   open  smtp
80/tcp   open  http
443/tcp  open  https
3005/tcp open  deslogin
3031/tcp open  epic

When I tried telnet [my.domain.ip] 443 remotely

Trying <my.domain.ip>...
telnet: connect to address <my.domain.ip>: Connection refused
telnet: Unable to connect to remote host

Lastly, I do not know if nginx.conf plays a part but below is a snippet of the code for the ssl for the domain

#include /etc/nginx/conf.d/*.conf;

server {
    listen          <my.domain.ip>:80;
    server_name     mydomain.com www.mydomain.com;
    index           index.html index.htm index.py;
    access_log      /var/log/nginx/mydomain.com.log;
    error_log       /var/log/nginx/mydomain.log.error;
    root            /home/fr/;
    charset         utf-8;

    #error_page 500 502 503 504 /custom_50x.html;
    #location = /custom_50x.html {
    #        internal;
    #}

    location / {
        uwsgi_pass  <my.domain.ip>:3031;
        include     uwsgi_params;
    }

    location /static {
        root        /home/fr/env/FRuler/fruler/;
    }
}

### for ssl  ###
server {
    listen          <my.domain.ip>:80;
    server_name     mydomain.com www.mydomain.com;
    index           index.html index.htm index.py;
    access_log      /var/log/nginx/mydomain.com.log;
    error_log       /var/log/nginx/mydomain.log.error;
    root            /home/fr/;
    charset         utf-8;


    location / {
        uwsgi_pass  <my.domain.ip>:3031;
        include     uwsgi_params;
    }

    location /static {
        root        /home/fr/env/FRuler/fruler/;
    }
}

server {
    listen 443 ssl;
    server_name     mydomain.com www.mydomain.com;
    ssl on;
    ssl_certificate /etc/ssl/mydomain/ssl.crt;
    ssl_certificate_key /etc/ssl/mydomain/server.key;
    server_name mydomain www.mydomain.com;
    access_log  /var/log/nginx/mydomain.com.log;
    error_log   /var/log/nginx/mydomain.log.error;
    location / {
        root /home/fr/;
        index index.html;
    }
}
### end of ssl ###

Any help is appreciated.

已采纳解答

原帖链接 · HBruijn · CC BY-SA 3.0

Order matters in iptables, rules are traversed sequentially.

REJECT     all  --  anywhere       anywhere        reject-with icmp-host-prohibited
ACCEPT     tcp  --  anywhere       anywhere        state NEW tcp dpt:https

After rejecting everything the subsequent rule opening port 443 for HTTPS will never be reached and have no effect. Your general reject rule should be last.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-04-15)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。