443端口无缘无故地连接到主机名

时间:2018-08-24 10:23:05

标签: php ssl nginx centos

我在https://hostname.example上经营一个网站 但是所有请求都通过https://hostname.example:443处理(该网站的先前开发人员告诉我们,应该在没有ssl端口的情况下将其过滤为主机名)

这似乎以一种不好的方式影响了网站-某些功能不起作用。

例如

a post request from the starting page of a website

信息:

CentOS 6.8。

nginx 1.10.2

存在并配置了SSL证书(不是我本人)

问题是:

  • 为什么以前没有做过所有请求的人都开始通过ssl端口?
  • 如何解决这个问题并使所有请求仅通过主机名进行处理?

请给我建议,以进一步说明问题中的内容。

UPD。

default.conf 
#
# The default server
#

server {
    listen       80 default_server;
#    listen       [::]:80 default_server;
server_name  www.hostname.example;

return 301 https://$server_name$request_uri;

#root         /path/to/root;
#index index.php index.html;

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

#location ~ ^/purge(/.*) {
#    allow     127.0.0.1;
#    allow     192.168.118.10;
#    deny     all;
#    fastcgi_cache_purge portalName $request_method$http_if_modified_since$http_if_none_match$host$1;
#}

#location / {
#}

#error_page 404 /404.html;
#    location = /40x.html {
#}

#error_page 500 502 503 504 /50x.html;
#    location = /50x.html {
#}

#location ~ \.php$ {
#    fastcgi_cache  portalName;
#   fastcgi_cache_valid 200 301 302 304 60m;
#   fastcgi_cache_key "$request_method$http_if_modified_since$http_if_none_match$host$request_uri";
#   fastcgi_pass_header "X-Accel-Expires";

#        set $no_cache 0;
#        fastcgi_cache  pubcache;
#        fastcgi_cache_valid 200 301 302 304 5m;
#        fastcgi_cache_key "$request_method|$http_if_modified_since|$http_if_none_match|$host|$request_uri";
#        fastcgi_cache_use_stale updating error timeout invalid_header http_500;

#        fastcgi_pass_header Set-Cookie;
#        fastcgi_pass_header Cookie;
#        fastcgi_ignore_headers Cache-Control Expires Set-Cookie;

#        fastcgi_cache_bypass $no_cache;
#        fastcgi_no_cache $no_cache;
#        proxy_cache_purge  PURGE from 127.0.0.1,192.168.118.10;

#    fastcgi_pass 127.0.0.1:9000;
##   fastcgi_pass unix:/var/run/php-fpm.sock;
#    fastcgi_index index.php;
#    fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
#    fastcgi_param HTTP_IF_NONE_MATCH $http_if_none_match;
#    fastcgi_param HTTP_IF_MODIFIED_SINCE $http_if_modified_since;
#    fastcgi_param HTTP_X_REAL_IP $remote_addr;
#    include        fastcgi_params;
#}
}








ssl.conf
#
# HTTPS server configuration
#

server {
    listen       443 ssl http2 default_server;
#    listen       [::]:443 ssl;
server_name  www.hostname.example;
root         /path/to/root;
index       index.php index.html;
#
#    ssl_certificate hostname.example.crt;
#    ssl_certificate_key  hostname.example.key;
ssl_certificate hostname_example.crt;
ssl_certificate_key  hostname_example.key;

ssl_session_cache shared:SSL:1m;
ssl_session_timeout  10m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
#
#    # Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
#
location / {
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }

    location ~ \.php$ {
        fastcgi_cache  portalName;
    fastcgi_cache_valid 200 301 302 304 60m;
    fastcgi_cache_key "$request_method$http_if_modified_since$http_if_none_match$host$request_uri";
    fastcgi_pass_header "X-Accel-Expires";

#        set $no_cache 0;
#        fastcgi_cache  pubcache;
#        fastcgi_cache_valid 200 301 302 304 5m;
#        fastcgi_cache_key "$request_method|$http_if_modified_since|$http_if_none_match|$host|$request_uri";
#        fastcgi_cache_use_stale updating error timeout invalid_header http_500;

#        fastcgi_pass_header Set-Cookie;
#        fastcgi_pass_header Cookie;
#        fastcgi_ignore_headers Cache-Control Expires Set-Cookie;

#        fastcgi_cache_bypass $no_cache;
#        fastcgi_no_cache $no_cache;
#        proxy_cache_purge  PURGE from 127.0.0.1,192.168.118.10;

        fastcgi_pass 127.0.0.1:9000;
    #   fastcgi_pass unix:/var/run/php-fpm.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        fastcgi_param HTTP_IF_NONE_MATCH $http_if_none_match;
        fastcgi_param HTTP_IF_MODIFIED_SINCE $http_if_modified_since;
        fastcgi_param HTTP_X_REAL_IP $remote_addr;
        include        fastcgi_params;
    }
}

UPD_2。好,谢谢大家的评论。我会去别的地方寻找问题的根源。

1 个答案:

答案 0 :(得分:0)

443是https的端口,因此存在一个原因。请求不能直接“转到主机名”,它必须始终是主机名和端口的组合。几乎总是浏览器根据协议选择端口,但您看不到它。

您在屏幕快照中看到的内容完全是正常现象,请在其他任何https站点上尝试使用,效果都一样。

或者您在其他地方有bug,或者您没有向我们显示问题中的问题。