Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ssl 使用nginx config为我的服务器上的单个目录强制https_Ssl_Nginx_Https_Nginx Location - Fatal编程技术网

Ssl 使用nginx config为我的服务器上的单个目录强制https

Ssl 使用nginx config为我的服务器上的单个目录强制https,ssl,nginx,https,nginx-location,Ssl,Nginx,Https,Nginx Location,我试图通过在我的nginx配置文件中放置重写规则来强制服务器上的单个子目录使用SSL 例如,当用户转到example.com/billing或example.com/billing/user时,他们会被带到或 我已安装SSL证书等。以下是我的nginx服务器块中的规则: #billing location location /billing/ { if (!-e $request_filename){ rewrite ^/billing/(.*)$ /billing/in

我试图通过在我的nginx配置文件中放置重写规则来强制服务器上的单个子目录使用SSL

例如,当用户转到example.com/billing或example.com/billing/user时,他们会被带到或

我已安装SSL证书等。以下是我的nginx服务器块中的规则:

#billing location
location /billing/ {
    if (!-e $request_filename){
        rewrite ^/billing/(.*)$ /billing/index.php?request=$1 last;
    }
}

有没有办法修改此规则以包括强制https?

我希望您有两个服务器块,一个用于http,另一个用于http SSL连接;在http服务器块中,在
/billing/
位置块中添加重定向到https将解决此问题

server {
 listen 80;
 location /billing/ {
   # 301 for permanent redirect
   return 301 https://$host$request_uri;
 }
}

我希望您有两个服务器块,一个用于http,另一个用于http SSL连接;在http服务器块中,在
/billing/
位置块中添加重定向到https将解决此问题

server {
 listen 80;
 location /billing/ {
   # 301 for permanent redirect
   return 301 https://$host$request_uri;
 }
}