This article is a mirror article of machine translation, please click here to jump to the original article.

View: 16571|Reply: 0

[Web] Nginx configures SSL and forces http to jump to https

[Copy link]
Posted on 11/2/2014 9:24:29 PM | | |
The configuration file is as follows

  1. server {
  2.     listen       80;
  3.     server_name ssl.lanbing.org;
  4.     rewrite ^/(.*) https://ssl.lanbing.org/$1 permanent; #关键代码
  5. }
  6. server
  7. {
  8.     listen 443;
  9.     server_name ssl.lanbing.org; #server_name end
  10.     index index.html index.htm index.php; #index end

  11.     set $subdomain '';
  12.     root  /home/wwwroot/ssl.lanbing.org/web$subdomain;
  13.     include rewrite/typecho.conf; #rewrite end

  14.     #error_page
  15.         error_page 403 /ErrorPages/403.html;
  16.         error_page 404 /ErrorPages/404.html;
  17.         location ~ /ErrorPages/(400|401|403|404|405|502|503)\.html$
  18.     {
  19.                 root /home/wwwroot/ssl.lanbing.org/web;
  20.         }


  21.     location ~ .*\.php$
  22.     {
  23.         fastcgi_pass  unix:/tmp/php-cgi-ssl.lanbing.org.sock;
  24.         fastcgi_index index.php;
  25.         include fcgi-host.conf;
  26.         fastcgi_param DOCUMENT_ROOT  /web$subdomain;
  27.         fastcgi_param SCRIPT_FILENAME  /web$subdomain$fastcgi_script_name;
  28.        }

  29.     location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp3|wma)$
  30.     {
  31.         expires      30d;
  32.     }

  33.     location ~ .*\.(js|css)$
  34.     {
  35.         expires      12h;
  36.     }

  37.     access_log off; #access_log end
  38.     error_log /dev/null; #error_log end
  39.     ssl on; #关键代码
  40.     ssl_certificate /usr/local/nginx/conf/ssl/ssl.lanbing.org.crt;  #关键代码
  41.     ssl_certificate_key /usr/local/nginx/conf/ssl/ssl.lanbing.org.pem; #关键代码
  42. }
Copy code






Previous:A penny to open a QQ green diamond, and Xiao Ma Ge is here to pit money again
Next:[Hurry up! ] The elementary school girl just dropped a money bag!!! Please pick it up and return it to a well-wisher]
Disclaimer:
All software, programming materials or articles published by Code Farmer Network are only for learning and research purposes; The above content shall not be used for commercial or illegal purposes, otherwise, users shall bear all consequences. The information on this site comes from the Internet, and copyright disputes have nothing to do with this site. You must completely delete the above content from your computer within 24 hours of downloading. If you like the program, please support genuine software, purchase registration, and get better genuine services. If there is any infringement, please contact us by email.

Mail To:help@itsvse.com