2013-09-30 122 views
1

美好的一天。我获得了网络应用程序和NGINX作为代理。 所以我需要我的主页与http协同工作。和所有其他网页与https。nginx重定向https单页

这里是我的NGINX配置:

server { 
     listen   80; 
     server_name    my-fin.ru www.my-fin.ru; 

     root   /usr/server/finance/abacus/webapp; 

     location ~ ^/.+\.(eot|ttf|woff)$ { 
      expires 1d; 
      add_header Cache-Control public; 
      add_header Access-Control-Allow-Origin *; 
     } 

     location ~ ^/.+\.(ico|jpg|jpeg|gif|pdf|jar|png|js|css|epf|svg)$ { 
      expires 1d; 
      add_header Cache-Control public; 
     } 
    location/{ 
       # give site more time to respond 
       proxy_read_timeout 120; 
       proxy_pass  http://127.0.0.1:8087; 
       proxy_redirect   http:// $scheme://; 

       proxy_set_header Host $host; 
       proxy_set_header X-Real-IP $remote_addr ; 
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ; 
     } 


} 

server { 
     listen   *:443; 
     server_name  my-fin.ru; 
     client_max_body_size 10m; 
     gzip     on; 
     gzip_min_length 500; 
     gzip_buffers 4 8k; 
     gzip_types    text/plain text/xml application/xml application/x-javascript text/javascript text/css text/json application/json; 

     access_log /var/log/nginx/finance.access.log; 
     error_log /var/log/nginx/finance.error.log; 

     ssl on; 
     ssl_certificate   /usr/server/myfin.crt; 
     ssl_certificate_key  /usr/server/myfin.key; 
     charset     utf-8; 

     root   /usr/server/finance/abacus/webapp; 

    rewrite https://my-fin.ru http://my-fin.ru;  
    location /logout { 
     return 301 http://my-fin.ru; 
    } 
     location ~ ^/.+\.(eot|ttf|woff)$ { 
      expires 1d; 
      add_header Cache-Control public; 
      add_header Access-Control-Allow-Origin *; 
     } 

     location ~ ^/.+\.(ico|jpg|jpeg|gif|pdf|jar|png|js|css|epf|svg)$ { 
      expires 1d; 
      add_header Cache-Control public; 
     } 
     location /features { 
       return 301 http://my-fin.ru/features; 
      } 
      location /price { 
       return 301 http://my-fin.ru/price; 
      } 
      location /help { 
       return 301 http://my-fin.ru/help; 
      } 
      location /about { 
       return 301 http://my-fin.ru/about; 
      } 

     location/{ 
       # give site more time to respond 
       proxy_read_timeout 120; 
       proxy_pass  http://127.0.0.1:8087/; 
       proxy_redirect   http:// $scheme://; 

       proxy_set_header Host $host; 
       proxy_set_header X-Real-IP $remote_addr ; 
       proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for ; 
     } 

} 

所以,我需要用户重定向从https://domain.ruhttp://domain.ru。对于所有其他页面,如https://domain.ru/help - 可以保持https连接。

请帮忙。

回答

0

把这个443服务器块

location =/{ 
     return 301 http://my-fin.ru/; 
    }