每次在地址行中改为域浏览器会显示服务器的 IP 地址。
请告诉我如何将其重定向到我的域名?我有以下设置,但没有用。
upstream app {
server unix:/home/deploy/sharetribe/tmp/sockets/puma.sock fail_timeout=0;
}
server {
listen 80;
listen [::]:80;
root /home/deploy/sharetribe/public;
try_files $uri/index.html $uri @app;
location @app {
proxy_pass http://app;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
}
server_name domain.name www.domain.name;
location / {
# root /home/deploy/sharetribe/public;
try_files $uri @app;
gzip_static on;
expires max;
proxy_read_timeout 150;
add_header Cache-Control public;
}
}
server {
listen 80;
server_name 12.123.12.12;
add_header X-Frame-Options "SAMEORIGIN";
#rewrite .* http://domian.name$request_uri permanent;
return 301 $scheme://domain.name$request_uri;
}
更新:
root@a:~# curl -I http://domain.name/
HTTP/1.1 301 Moved Permanently
Server: nginx/1.10.2
Date: Sat, 11 Mar 2017 19:42:06 GMT
Content-Type: text/html
Content-Length: 185
Connection: keep-alive
Location: http://domain.name/
X-Frame-Options: SAMEORIGIN
Google Chrome 中显示错误:domain.name 将您重定向过多次。