server {
listen 8080 default_server;
listen [::]:8080 default_server;
server_name cad.domain.tech;
root /var/www/cad;
index index.php;
location ~* \.php$ {
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
} 我在我的NGINX网站上有这个-availables,当我做IP:8080的时候,我得到了我放在那里的网页。然而,当我执行cad.domain.tech时,我得到“服务器找不到”。
以下是我的页面规则和DNS设置:


有谁有什么想法吗?
发布于 2019-10-29 18:05:28
这是因为当访问http://cad.domain.tech时,它默认在端口80上请求您的服务器(如果请求以https://开始,则为端口443 )。
因此,您需要做的就是将端口80上的所有传入请求重定向到您的示例中的端口8080。
server {
listen 80;
listen [::]:80;
hostname cad.domain.tech www.cad.domain.tech;
return 301 http://cad.domain.tech:8080
}这应该是可行的。return 301告诉请求者这是一个永久重定向。
https://stackoverflow.com/questions/58578903
复制相似问题