location

Nginx系列之静态服务

房东的猫 提交于 2020-02-26 02:04:31
博文大纲: 1)静态资源类型 2)静态资源场景 3)静态资源配置语法 4)静态资源文件压缩 5)静态资源浏览器缓存 6)静态资源防盗链 1)静态资源类型 Nginx作为静态资源web服务器部署配置,传输非常的高效,常常用于静态资源处理、请求、动静分离! 非服务器动态运行生成的文件属于静态资源! 类型 种类 浏览器端渲染 HTML、CSS、JS 图片 JPEG、GIF、PNG 视频 FLV、MP4 文件 TXT、任意下载文件 2)静态资源场景 静态资源传输延迟最小化! 如图: 3)静态资源配置语法 1)文件读取高效——>sendfile Syntax:sendfile on | off ; Default:sendfile off ; Context:http、server、location、if in location ; 2)提高网络传输效率——>nopush Syntax:tcp_nopush on | off ; Default:tcp_nopush off ; Context:http、server、location ; 作用: sendfile开启情况下, 提⾼⽹络包的'传输效率'; 3)与 tcp_nopush 之对应的配置 tcp_nodelay Syntax: tcp_nodelay on | off ; Default: tcp_nodelay on ;

一台服务器Nginx配置多个域名(一级域名或二级)

爱⌒轻易说出口 提交于 2020-02-26 00:14:03
需求描述: 一台服务器(ip: 39.105.1xx.xx)上启nginx,然后配置多个server,分别将不同一级域名或二级域名。 实现方法(不说废话了,直接上代码,看懂的来): 注意我是两个一级域名(.com和.cn) server { listen 80; server_name testapp.com; location / { root /usr/share/nginx/html/official_web/; index index.html index.htm; # try_files $uri $uri/ /index.html; } } server { listen 80; server_name testapp.cn; location / { root /usr/share/nginx/html/official_web/zhoubianbaoapp; index index.html index.htm; # try_files $uri $uri/ /index.html; } } 另外,如果是多个二级域名,也是跟上面一模一样的。(亲测) 延展问题:在testapp.com下配置oms系统,访问路径http://testapp.com/oms 发现配置的 http://testapp.com 可以访问,但是http://testapp.com

nginx location

自闭症网瘾萝莉.ら 提交于 2020-02-25 22:27:10
nginx location配置问题 场景:nginx 作为网关服务,nodejs服务作为后台服务    domain.com/ 对接后台API    如 domain.com/company/:id, domain.com/user/:id 等 修改需求如下:domain.com/ 输出index.html 展示官网;nginx承担前端静态服务 理想情况是 /api 区分接口请求与非接口请求。为不带来较大影响,现需要nginx识别出 / 与 /**/** , 并在 / 请求时正常输出静态页面。    location 配置如下: 1 location = / { 2 root /home/index/; 3 index index.html index.htm; 4 } 5 6 7 location ~* / { 8 proxy_pass http://127.0.0.1:3000; 9 } 理想与现实总是有差距,当前配置经过实验后任然无法如预期的样子。domain.com/ 的请求任然会被转发到3000的服务中。 发生了什么?为什么会这样呢? 经过查阅相关文档发现, 1 location = / { 2 root /home/index/; 3 index index.html index.htm; 4 } location = / 为精确匹配; 当nginx匹配到

js 页面刷新

会有一股神秘感。 提交于 2020-02-25 15:51:44
页面自动刷新代码大全,基本上所有要求自动刷新页面的代码都有,大家可以自由发挥做出完美的页面。 1) 10表示间隔10秒刷新一次 2) <script> window.location.reload(true); </script> 如果是你要刷新某一个iframe就把window给换成frame的名字或ID号 3) <script> window.navigate("本页面url"); </script> 4> function abc() { window.location.href="/blog/window.location.href"; setTimeout("abc()",10000); } 刷新本页: Response.Write("<script>window.location.href=window.location.href;</script>") 刷新父页: Response.Write("<script>opener.location.href=opener.location.href;</script>") 转到指定页: Response.Write("<script>window.location.href='yourpage.aspx';</script>") 刷新页面实现方式总结(HTML,ASP,JS) 'by aloxy 定时刷新: 1,

nginx 之 proxy_pass详解

泄露秘密 提交于 2020-02-24 12:48:21
在nginx中配置proxy_pass代理转发时,如果在proxy_pass后面的url加/,表示绝对根路径;如果没有/,表示相对路径,把匹配的路径部分也给代理走。 假设下面四种情况分别用 http://192.168.1.1/proxy/test.html 进行访问。 第一种: location /proxy/ { proxy_pass http://127.0.0.1/; } 代理到URL: http://127.0.0.1/test.html 第二种(相对于第一种,最后少一个 / ) location /proxy/ { proxy_pass http://127.0.0.1; } 代理到URL: http://127.0.0.1/proxy/test.html 第三种: location /proxy/ { proxy_pass http://127.0.0.1/aaa/ ; } 代理到URL: http://127.0.0.1/aaa/test.html 第四种(相对于第三种,最后少一个 / ) location /proxy/ { proxy_pass http://127.0.0.1/aaa ; } 代理到URL: http://127.0.0.1/aaatest.html nginx中有两个模块都有 proxy_pass 指令。 ngx_http_proxy

Nginx-2.初学者使用

拜拜、爱过 提交于 2020-02-24 09:42:38
原文 Nginx有一个master进程和几个worker进程。master进程用来读取和评估配置文件,以及维护worker进程。worker进程用来处理实际的请求。Nginx使用事件模型和基于操作系统的逻辑来实现高效的worker处理进程。worker进程的数量可以定义到配置文件中,或者根据cpu核心数来自动调节。 默认配置文件 nginx.conf ,默认地址 nginx/conf 。 启动,停止,重新加载配置文件 语法 nginx -s signal signal 可以是以下几个: stop 快速停止 quit 优雅停止 reload 重新加载配置文件 reopen 重新打开配置文件 demo: nginx -s quit #优雅的停止。和启动的用户必须是同一个。 nginx -s reload #改了配置文件要重洗加载生效。 nginx收到reload信号之后,master进程会检查配置文件,如果没有过,回滚配置,继续使用旧的配置文件。如果过了,会先生成一个新的worker进程,然后给老的worker进程发送信号。老的worker进程收到消息会停止接收新的连接,但是会执行完已经存在的连接,最后退出。 Unix系统的 kill 命令也可以用来发送signal给nginx。假设nginx的master进程id是1628,使用下面格式 kill -QUIT 1628 ps

Nginx虚拟主机配置实例(Nginx VirtualHost Example)

感情迁移 提交于 2020-02-23 01:49:48
两个虚拟主机(纯静态-html 支持) - Two Virtual Hosts, Serving Static Files http { : server { : listen 80; : server_name www.domain1.com; : access_log logs/domain1.access.log main; : location / { : index index.html; : root /var/www/domain1.com/htdocs; : } : } : server { : listen 80; : server_name www.domain2.com; : access_log logs/domain2.access.log main; : location / { : index index.html; : root /var/www/domain2.com/htdocs; : } : } } 虚拟主机标准配置(简化) - A Default Catchall Virtual Host http { : server { : listen 80 default; : server_name _ *; : access_log logs/default.access.log main; : location / { : index

linux nginx 完整安装配置笔记

岁酱吖の 提交于 2020-02-21 12:42:59
准备工作:阿里云 centos 7.6 X86_64、nginx 1.16.0.tar.gz 1、下载nginx nginx官网:http://nginx.org/en/download.html 2、安装 a、将压缩包解压到任意(不要含有中文及特殊字符)目录(目录自定)下,这个压缩包默认解压为nginx-1.16.0 b、进入解压目录进行安装,依次执行以下命令 ./configure、make、make install 若无错误提示,则表示安装成功!若出错一般为linux内核版本过低,没有提供相应的组件包(gcc、pcre、pcre-devel、zlib),到以下网站进行下载安装即可, https://sourceforge.net/projects 3、配置:包含多站点或多域名 切换至/usr/local/nginx/conf目录下,执行vi nginx.conf 命令,按以下内容配置,如下: #user root; worker_processes auto; #error_log logs/error.log; #error_log logs/error.log notice; #error_log logs/error.log info; #pid logs/nginx.pid; events { worker_connections 1024; } http {

Facebook API Friend Location object being returned with empty string for id and null for name

巧了我就是萌 提交于 2020-02-21 04:58:22
问题 Yesterday, when I retrieved my Facebook Friends from the Graph API using the query "me/friends?fields=id,location" 500+ came back with location data. Today, 500+ are returned with the location object, but only 36 have any data in the location object, the rest are returned as: "location": { "id": "", "name": null } You can reproduce it yourself in the Graph API Explorer. You'll see that some friends have legitimate locations, but the majority have the null values. Does anyone have any idea

Getting Speed using Google Play Location API

大憨熊 提交于 2020-02-20 09:25:10
问题 I am using fused location provider from the new GooglePlay API(LocationClient class). But the method Location.GetSpeed() is not returning correct speed (shows 0). I read that I have to use LocationManager class to get the speed, but when I tried LocationManager a new problem occured. The location manager NetworkProvider is not working, here is a thread with the problem http://code.google.com/p/android/issues/detail?id=57707 . So what is the best way to get the speed of movement. I tried