Nginx配置同一個域名http與https兩種方式都可訪問


##配置

http://test.pay.joyhj.com

https://test.pay.joyhj.com

兩者都可訪問

# vim /usr/local/nginx/conf/vhost/test.pay.joyhj.com.conf
server
{
  listen 80;
  listen 443 ssl;  ##把ssl on;這行注釋掉, ssl寫在443端口后面, 這樣http和https的鏈接都可以用
  server_name test.pay.joyhj.com;
  index index.html index.htm index.php;
  root /data/www/hjtestpay;
  charset utf-8;

  location ~.*\.(swf|xml|mp3|png|jpg|gif|data)$ {
    expires max;
  }

  location ~.*\.(css|js|mx)$ {

    expires 96h;
  }

  location ~* \.(bak|save|sh|sql|mdb|svn|git|old)$ {

    #rewrite ^/(.*)$ $host permanent;
    return 403;
  }

  location ~ .*\.php$ { 

    include fastcgi.conf;
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    expires off;
  }

#   ssl on;  ##把ssl on;這行注釋掉, ssl寫在443端口后面, 這樣http和https的鏈接都可以用
  ssl_certificate /usr/local/nginx/ssl/test.pay.joyhj.com_cert.crt;
  ssl_certificate_key /usr/local/nginx/ssl/test.pay.joyhj.com.key;

  access_log /data/logs/test.pay.joyhj.com.access.log access;
  error_log   /data/logs/test.pay.joyhj.com.error.log warn;

}

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM