我有一些困难,试图将所有的东西转到nginx上的子域。我使用cloudflare运行子域,这就是为什么我需要将流量重定向到这个子域。
*.soldadinhos.global -> site.soldadinhos.global
soldadinhos.global -> site.soldadinhos.global
我该怎么做?
server {
server_name site.soldadinhos.global;
location / {
root /usr/share/nginx/html;
index index.html index.htm index.php;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
root /usr/share/nginx/html;
include fastcgi.conf;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/soldadinhos.global/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/soldadinhos.global/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
server_name *.soldadinhos.global soldadinhos.global;
listen 80;
return 301 https://site.soldadinhos.global;
}编辑:我修改了conf文件,它现在正在工作,但是如果我访问www.soldadinhos.global/somefile.php,它不会重定向到site.soldadinhos.global/somefile.php。
发布于 2018-07-02 18:25:23
您可以执行以下操作:
server {
server_name *.example.com example.com;
listen 80;
return 301 http://site.example.com$request_uri;
}您需要从现有配置中删除example.com。
然后,您需要向指向此服务器的DNS添加相应的DNS A记录。
https://serverfault.com/questions/918916
复制相似问题