Nginx站点配置及https配置

2019-01-16   阅读:2313   分类:后端    标签: 服务器

Nginx是一款轻量级的Web 服务器/反向代理服务器及电子邮件(IMAP/POP3)代理服务器,并在一个BSD-like 协议下发行。其特点是占有内存少,并发能力强,事实上nginx的并发能力确实在同类型的网页服务器中表现较好,中国大陆使用nginx网站用户有:百度、京东、新浪、网易、腾讯、淘宝等。以下是nginx站点配置及https配置实例:

默认:

server
    {
        listen 80;
        server_name baidu.tpxhm.com;
        index index.php index.html index.htm default.html default.htm default.php;
        root  /mydata/wwwroot/baidu.tpxhm.com;

        #error_page   404   /404.html;
        location ~ [^/]\.php(/|$)
        {
            # comment try_files $uri =404; to enable pathinfo
            try_files $uri =404;
            fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_index index.php;
            include fastcgi.conf;
            #include pathinfo.conf;
        }
		location / {
			if (!-e $request_filename) {
				rewrite ^(.*)$ /index.php?s=/$1 last;
				break;
			}
		}

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        access_log  off;
    }

https配置:

server
    {	
	listen 443;
        server_name baidu.tpxhm.com;
        index index.php index.html index.htm default.html default.htm default.php;
        root  /mydata/wwwroot/baidu.tpxhm.com;
		
		ssl on;
		ssl_certificate /etc/live/baidu.tpxhm.com/fullchain.pem;
		ssl_certificate_key /etc/live/baidu.tpxhm.com/privkey.pem;
		ssl_dhparam /etc/ssl/certs/dhparams.pem;
		ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
		ssl_ciphers HIGH:!aNULL:!MD5;
		
        #error_page   404   /404.html;
        location ~ [^/]\.php(/|$)
        {
            # comment try_files $uri =404; to enable pathinfo
            try_files $uri =404;
            fastcgi_pass  unix:/tmp/php-cgi.sock;
            fastcgi_index index.php;
            include fastcgi.conf;
            #include pathinfo.conf;
        }
		location / {
			 if (!-e $request_filename) {
			   rewrite  ^(.*)$  /index.php?s=/$1  last;
			   break;
				}
		}

        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
        {
            expires      30d;
        }

        location ~ .*\.(js|css)?$
        {
            expires      12h;
        }

        access_log  off;
    }
server {
    listen 80;
    server_name baidu.tpxhm.com;
    return 301 https://$server_name$request_uri;
}


【腾讯云】 爆款2核2G3M云服务器首年 61元,2核2G4M云服务器新老同享 99元/年,续费同价

‘简忆博客’微信公众号 扫码关注‘简忆博客’微信公众号,获取最新文章动态
转载:请说明文章出处“来源简忆博客”。http://www.tpxhm.com/adetail/100.html

×
觉得文章有用就打赏一下文章作者
微信扫一扫打赏 微信扫一扫打赏
支付宝扫一扫打赏 支付宝扫一扫打赏

文章评论(0)

登录
简忆博客壁纸一
简忆博客壁纸二
简忆博客壁纸三
简忆博客壁纸四
简忆博客壁纸五
简忆博客壁纸六
简忆博客壁纸七
简忆博客壁纸八
头像

简忆博客
勤于学习,乐于分享

置顶推荐

打赏本站

如果你觉得本站很棒,可以通过扫码支付打赏哦!
微信扫码:你说多少就多少~
微信扫码
支付宝扫码:你说多少就多少~
支付宝扫码
×