首页 > Web开发 > 详细

Nginx httpS server配置

时间:2015-12-02 18:02:34      阅读:358      评论:0      收藏:0      [点我收藏+]

Nginx httpS server配置

配置同时支持http和httpS协议:

server { listen
80 default backlog=2048;
     #backlog:每个网络接口接收数据包的速率比内核处理这些包的速率快时,允许送到队列的数据包的最大数目。 listen
443 ssl; server_name ssl.joy4you.com; ssl_certificate /data/nginx/conf/server.crt; ssl_certificate_key /data/nginx/conf/server_nopwd.key; root /data/; location / { index index.php index.html index.htm; try_files $uri $uri/ /index.php?$args; } location ~ .*\.(php|php5)?$ { # try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi.conf; } }

 

配置/data/http/使用http协议;/data/ssl/使用httpS协议:

server { listen
80; server_name 192.168.17.16; access_log /data/nginx/logs/php.joy4you.com.log main; root /data/http/; location / { index index.php index.html index.htm; try_files $uri $uri/ /index.php?$args; } location ~ .*\.(php|php5)?$ { # try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi.conf; } } server { listen 443; ssl on; ssl_certificate /data/nginx/conf/server.crt; ssl_certificate_key /data/nginx/conf/server_nopwd.key; server_name 192.168.17.16; access_log /data/nginx/logs/php.joy4you.com.log main; root /data/ssl/; location / { index index.php index.html index.htm; try_files $uri $uri/ /index.php?$args; } location ~ .*\.(php|php5)?$ { # try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi.conf; } }

 

把访问80端口的请求全部转发到443(https):

server { listen
80; server_name 192.168.17.16; rewrite ^(.*) https://$server_name$1 permanent; } server { listen 443; ssl on; ssl_certificate /data/nginx/conf/server.crt; ssl_certificate_key /data/nginx/conf/server_nopwd.key; server_name 192.168.17.16; access_log /data/nginx/logs/php.joy4you.com.log main; root /data/; location / { index index.php index.html index.htm; try_files $uri $uri/ /index.php?$args; } location ~ .*\.(php|php5)?$ { # try_files $uri =404; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.php; # fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi.conf; } }

 

Nginx httpS server配置

原文:http://www.cnblogs.com/tangshengwei/p/5013341.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!