Node.js 无法使用nginx显示域名而不是IP
我在digitaloceans中配置了node.js api,并尝试使用nginx显示mydomain.com而不是IP服务器。我的默认nginx配置中有以下配置:Node.js 无法使用nginx显示域名而不是IP,node.js,nginx,Node.js,Nginx,我在digitaloceans中配置了node.js api,并尝试使用nginx显示mydomain.com而不是IP服务器。我的默认nginx配置中有以下配置: server { keepalive_timeout 30; listen server_ip:443 ssl; ssl_certificate /tmp/mycrt.crt; ssl_certificate_key /tmp/mykey.key; ssl_session_cache sha
server {
keepalive_timeout 30;
listen server_ip:443 ssl;
ssl_certificate /tmp/mycrt.crt;
ssl_certificate_key /tmp/mykey.key;
ssl_session_cache shared:SSL:10m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_session_timeout 10m;
server_name _;
location / {
proxy_pass http://server_ip:8000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;}
}
我将域名配置为IP服务器的域记录。它重定向到我的服务器,但它改为而不是
我错过了什么?
谢谢。您需要在配置文件中添加以下代码:
server {
listen 80;
# Listen to your server ip address
server_name your-server-ip;
# Redirect all traffic comming from your-server-ip to your domain
return 301 $scheme://example.com$request_uri;
}
有关更多详细信息,请按照中的步骤进行操作。我将按照以下步骤进行求解
谢谢。您遗漏了一份退货声明。请检查下面的答案以及答案中的链接。谢谢,如果我尝试输入此代码,请在输入时要求我下载一个文件(应用程序/八位字节流),一个空文件。