2017-07-31 163 views
1

我尝试使用NGINX将HTTPS请求重定向到HTTP。NGINX将HTTPS重定向到HTTP

这个我怎么编辑

的/ etc/nginx的/网站可用/默认

在我的VPS:

server { 
    listen  443; 
    server_name exapmle.com; 
    rewrite ^(.*) http://example.com$1 permanent; 
} 

server { 
     listen 80 default_server; 
     listen [::]:80 default_server; 
     root /var/www/laravel/public; 

     index index.php index.html index.htm index.nginx-debian.html; 

     server_name example.com www.example.com; 

     if ($https = "on") { 
       return 301 http://www.example.com$request_uri; 
     } 

     location/{ 
       try_files $uri $uri/ /index.php?$query_string; 
     } 
     location ~ \.php$ { 
       include snippets/fastcgi-php.conf; 
       fastcgi_pass unix:/run/php/php7.0-fpm.sock; 
     } 
     location ~ /\.ht { 
       deny all; 
     } 
} 

所以我做了什么错什么想法?

+1

出于好奇,为什么你要重定向HTTPS到http? – Difster

+0

我尝试运行Google广告,但他们不接受我的广告,因为这样:https://support.google.com/adwordspolicy/answer/6368661?hl = zh_CN&authuser = 0#673 –

+0

@Difster在我的广告中声称:目的地不工作 –

回答

2

您需要侦听端口443(HTTPS)并重定向到HTTP。你没有什么表明您正在收听的443

试试这个:

server { 
listen  443; 
server_name exapmle.com; 
rewrite ^(.*) http://example.com$1 permanent; 

}

+0

'服务器{441; server_name example.com; return 301 http://www.example.com$request_uri; }'它是不是看起来像这样? –

+0

这看起来正确。测试一下,看看它是如何工作的。 – Difster

+0

这应该一般工作,也许你是从错误的角度接近问题。你是说这不适合你的广告,或者它不适用于任何东西?让我知道。 – Difster