nginx:具有动态ip的服务器的重定向请求

时间:2015-07-29 20:48:41

标签: http redirect nginx https configuration

我在路由器后面设置了一个nginx服务器,每天都有一个新的ip-adress。

现在我想通过

重定向访问该网站的每个用户
  

http://[IP]/

  

https://[IP]/

这在本地网络中运行良好,但如果我从外部访问该网站,它显然不会。

这是我的nginx配置文件的摘录(/ etc / nginx / sites-avaliable / ...)

server_name $hostname;

ssl_certificate /etc/nginx/ssl/nginx.crt;
ssl_certificate_key /etc/nginx/ssl/nginx.key
# redirect to HTTPS
if ($scheme = http) {
     return 301 https://$server_name$request_uri;
}

当公共IP发生变化时,如何每天更改server_name? 我不能使用像dyndns或noIP这样的东西。

甚至可以在运行时更改此项而无需重新启动nginx吗?

0 个答案:

没有答案