学习nginx久了我们通常会有一些常用的配置了,下面我给大家整理了Nginx配置中像域名跳转 https域名跳转跳到http或 cdn配置一些例子,希望能帮助各位.
www跳转到主域名,代码如下:
- server{
- listen80;
- server_namewww.phpfensi.com;
- access_logoff;
- error_logoff;
- return301http://tool.lu$request_uri;
- }
http跳转到https,代码如下:
- server{
- listen80;
- server_nametool.lu;
- return301https://tool.lu$request_uri;
- }
fastcgi,代码如下:
- location~.php${
- try_files$uri=404;
- fastcgi_pass127.0.0.1:9000;
- fastcgi_indexindex.php;
- fastcgi_paramSCRIPT_FILENAME$document_root$fastcgi_script_name;--phpfensi.com
- includefastcgi_params;
- }
cdn,代码如下:
- server{
- listen80;
- server_names1.tool.lus2.tool.lus3.tool.lus4.tool.lu;
- root/data/html/tool.lu/static;
- indexindex.html;
- access_logoff;
- error_logoff;
- location/{
- concaton;
- concat_typestext/cssapplication/javascript;
- #解决js语句不以分号结尾的第三方库
- concat_delimiter"nn";
- concat_max_files20;
- expires7d;
- }
- }