我遇到了一个问题,默认的HTTPS端口443已被使用。我将其切换到端口444,但现在我的网站只能通过'example.com:444'访问,当我尝试通过'https://example.com'访问我的网站时,它不起作用。如何在不显式指定端口的情况下配置它以使其工作?
这是我的nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 80;
server_name example.com www.example.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://localhost:8080;
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;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
# HTTPS server
#
server {
#listen 444 ssl http2 default_server;
#listen [::]:444 ssl http2 default_server;
listen 444 ssl;
server_name example.com www.example.com;
# Disable root application access. You may want to allow this in development.
#location ~ ^/$ {
# return 404;
#}
ssl_certificate C:\Users\Administrator\Desktop\ssl\wildcard24.pem;
ssl_certificate_key C:\Users\Administrator\Desktop\ssl\wildcard24.pem;
ssl_password_file C:\Users\Administrator\Desktop\ssl\psw.txt;
ssl_session_cache shared:SSL:1m;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
proxy_pass http://localhost:8080;
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;
}
}
}
字符串
i希望在没有显式指定端口的情况下工作?
是否可以将我的服务器配置为侦听端口443,并确保所有请求(包括根URL(https://example.com)和子路径(例如https://example.com/map))都被重定向到同一端口上的所需页面,从而无需在URL中指定端口号?
1条答案
按热度按时间cgyqldqp1#
HTTPS URL假定默认端口为443。(历史上HTTP URL假定为80)。
如果某个东西在端口444上运行,如果没有明确说明该端口号的URL,您就无法访问它。
如果这更多的是为了书签和方便(而不是隐藏端口号的外观必须是显式的),管理员通常会配置443服务器重定向到444服务器(https://example.com/other_server-> https://example.com:443/)
还有其他更严肃的解决方案,更像是“服务器故障”(管理/配置)堆栈交换。