我有一台服务器,它只能提供 HTTPS 服务,并且我可以拥有由用户动态创建的域或子域,并由应用程序本身处理。
我尝试使用返回和重定向,但当通过访问网站时http,它要求下载一个二进制文件。
这是我的配置:
server {
listen 80;
server_name _;
# any of option below gives same behaviour
rewrite ^ https://$host$request_uri? permanent;
return 301 https://$host$request_uri;
}
server {
listen 443 http2 default_server;
listen [::]:443 http2;
ssl on;
server_name _;
port_in_redirect off;
access_log /var/log/nginx/app.xx.com.br.access.log combined;
error_log /var/log/nginx/app.xx.com.br.error.log;
root /var/www/html/app.xx.com.br/public_html;
index index.html;
ssl_certificate /etc/letsencrypt/live/xx.com.br/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/xx.com.br/privkey.pem;
location / {
try_files $uri $uri/ /index.html?$args;
#try_files $uri $uri/ =404;
}
}
任何帮助都值得感激。谢谢
编辑
CURL 请求/响应
MB-Pro-2:~ user$ curl -v http://app.host.com.br
* Rebuilt URL to: http://app.host.com.br/
* Trying 18.xxx.xxx.xxx...
* TCP_NODELAY set
* Connected to app.proiot.com.br (18.xxx.xxx.xxx) port 80 (#0)
> GET / HTTP/1.1
> Host: app.host.com.br
> User-Agent: curl/7.54.0
> Accept: */*
>
* Connection #0 to host app.host.com.br left intact
���
如果我在 Firefox 检查器上查看响应(���),我会得到:
它只是没有重定向。