【发布时间】:2015-04-21 13:39:25
【问题描述】:
我想在我的 nginx 配置中从我的 url 中删除 www 并查看文档和堆栈溢出帖子,我编写了以下配置,但它似乎不起作用。
server_name {
server_name www.subdomain.domain.com;
rewrite ^(.*) https://subdomain.domain.com/$1 permanent
}
server_name {
server_name subdomain.domain.com;
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
root /file;
index index.html index.htm app.js;
location /{
proxy_pass https://subdomain.domain.com:443/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location /*/ {
proxy_pass https://subdomain.domain.com:443/;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
# Only for nginx-naxsi used with nginx-naxsi-ui : process denied requests
#location /RequestDenied {
# proxy_pass http://127.0.0.1:8080;
#}
error_page 404 /404.html;
}
但它似乎根本不起作用。但是,每当我尝试使用 www.subdomain.domain.com 访问该站点时,我都无法访问该站点,但是 https://subdomain.domain.com 工作正常。任何关于这方面的建议都将非常感谢。
【问题讨论】:
-
你有很多语法错误。你重启nginx了吗?
标签: nginx