Articles of http

Nginx位置configuration(子文件夹)

可以说我有一个像这样的path: /var/www/myside/ 该path包含两个文件夹…让我们说/static和/manage 我想configurationnginx来访问: /static文件夹/ (例如http://example.org/ )这个文件夹有一些.html文件。 /manage文件夹/manage (例如http://example.org/manage )在这种情况下,这个文件夹包含Slim的PHP框架代码 – 这意味着index.php文件是在public子文件夹(例如/ var / www / mysite /manage/public/index.php) 我已经尝试了很多组合,如 server { listen 80; server_name example.org; error_log /usr/local/etc/nginx/logs/mysite/error.log; access_log /usr/local/etc/nginx/logs/mysite/access.log; root /var/www/mysite; location /manage { root $uri/manage/public; try_files $uri /index.php$is_args$args; } location / { root $uri/static/; index index.html; } location ~ \.php { try_files $uri =404; […]

自动刷新502网关错误的网页错误

当我在我的网站上进行维护并重新启动服务器时,有时NGINX返回502错误的网关错误。 同样的事情有时在重负载下发生。 这让我的访问者感到困惑,他们没有意识到这个问题可能是暂时的。 有什么方法可以让访问者在网站返回时自动刷新页面?

Chrome会忽略ETag标头,只是使用内存caching/磁盘caching

如果我理解正确,那么使用ETags的stream程如下所述: 浏览器将请求发送到服务器。 服务器用ETag发回图像 浏览器随同ETag一起保存资源 在下一个请求中,浏览器发送带有包含保存的ETag的头部If-None-Match的请求。 当返回响应时,chrome开发工具告诉我这些是我的头文件 Cache-Control:max-age=7200 Connection:keep-alive Content-Type:image/png Date:Thu, 27 Apr 2017 13:42:57 GMT ETag:"b36f59c868d4678033d318a182658e18371df8f5" Expires:Thu, 27 Apr 2017 15:42:57 GMT Server:nginx Transfer-Encoding:chunked X-Debug-Token:873c8f X-Debug-Token-Link:http://localhost:8081/_profiler/873c8f 现在,当我重新加载页面时,不会收集新的图像。 它通过Chrome的内存caching或磁盘caching保存,如您在这里看到的 但为什么会这样呢? 我发送了一个ETag,为什么浏览器不向服务器发出另一个请求,而是使用它自己的caching? 我问的原因是,我们想要caching我们的图像,但只要他们改变,他们应该立即更新。 为什么Chrome会这样做? 更新 我只是注意到它在Firefox上的作用,所以这似乎是一个铬“function”,而不是一个configuration。 更新2 设置我的新标题像这样的图像 Cache-Control:max-age=0, private Connection:keep-alive Content-Type:image/png Date:Thu, 27 Apr 2017 14:44:57 GMT ETag:"e5b18bdebe44ed4bba3acb6584d9e6a81692ee27" Expires:Fri, 27 Oct 2017 14:44:57 GMT Server:nginx Transfer-Encoding:chunked […]

Nginx + Gunicorn POST请求错误

我使用nginx作为使用gunicorn的Django应用程序的代理,问题是,在某些时候,我收到来自另一个站点的POST请求。 问题似乎是,nginx没有正确地将POST请求redirect到gunicorn守护进程。 我能做些什么来解决这个问题,我需要的是能够发送POST请求,因为它到达我的django应用程序的gunicorn daemor来处理它…谢谢你… 这是我的nginx conf server { server_name www.rinconcolombia.com; access_log /var/log/nginx/rinconcolombia.log; location / { ssi on; proxy_pass http://127.0.0.1:8888; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; } location /static/ { autoindex on; root /home/rincon/sites/rinconcolombia/checkouts/rinconcolombia/; } location /static/admin_media/ { autoindex on; root /home/rincon/sites/rinconcolombia/checkouts/rinconcolombia/; } } server { server_name www.rinconcolombia.com; rewrite ^(.*) http://www.rinconcolombia.com$1; } 更新发送应用程序的应用程序正在收到一个坏请求错误…如果我手动使用resty或curl […]

在nginx中查看带有问号的文件

我有一些代码使用wget来镜像一些页面,而一些要镜像的页面是像“http://example.com/somepage.php?id=1234”这样的链接。 wget最终将这些页面保存为“somepage.php?id = 1234.html”。 当我试图访问该页面时,我得到一个404。 我尝试添加“autoindex”; 到该目录的configuration,以确保文件名是正确的,当我访问包含该页面的目录时,点击由nginx生成的链接,我仍然得到一个404。 我怎样才能让nginx服务页面上的问号?

Django:行被删除后仍然显示 – 由于caching?

我写了一个使用DataTables的Django应用程序。 问题是当我从表中删除一行时,它仍然显示在表中运行nginx / gunicorn时。 但是,当我运行在Djangotesting服务器上时,它正常工作。 所以如果我用这个命令行启动一个服务器: python manage.py runserver 192.168.0.1:8000 一切正常。 也就是说,我删除该行,表刷新,并且不显示已删除的行。 这是HTTP调用的摘要: // An initial GET command to populate the table GET /myapp/get_list (returns a list to display) // I now select a row and delete it which causes this POST to fire POST /myapp/delete (deletes a row from the list) // After the […]

使用NGINX进行浏览器function检测

有谁知道NGINX的插件,允许服务器提供基于浏览器function的特定文件? 例如: if(Browser.Features.CSS3) { url.rewrite …/super_combined_css.css } else { url.rewrite …/basic_combined_css.css } 我假设它只是有一个预定义的浏览器列表,存在属于某些类别(如CSS3支持,CSSanimation,SVG支持等)。 一旦请求进入,它只是分析用户代理string,以找出浏览器属于什么类别。 有任何想法吗?

在nginx反向代理上的应用redirect错误

我正在运行一个nginx(0.7.67)作为反向代理和一个golang应用程序。 nginx服务器configuration如下: … location /bar/ { proxy_pass http://localhost:8088/; proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; } … 我的golang应用程序的来源(这是没有道理的,只是一个例子): func root(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, "You reached root") } func foo(w http.ResponseWriter, r *http.Request) { http.Redirect(w, r, "/", http.StatusFound) } func main() { http.HandleFunc("/", root) http.HandleFunc("/foo", foo) http.ListenAndServe("localhost:8088", […]

Nginx正在侦听端口80或443,但没有响应

我的服务器工作得很好,直到几个小时前,当它不知何故停止接听电话, 我觉得独angular兽工作正常(curl本地主机:3000工程 – 其中3000是独angular兽的港口) 我跑了: sudo netstat -anltp Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 5664/mysqld tcp 0 0 my.public.ip.address:80 0.0.0.0:* LISTEN 6825/nginx tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 2737/sshd tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 6389/unicorn.rb -E tcp 0 […]

我如何使用nginx作为Golang的反向代理?

我想使用Golang作为我的服务器端语言,但是我读过的所有内容都指向了nginx作为web服务器,而不是依赖于net/http (不是说它很糟糕,但总体上看起来更好,不是这篇文章的重点虽然)。 我已经find了一些关于使用Golang的fastcgi的文章,但是我没有find任何有关反向代理和HTTP的东西,除了这个基准testing ,不幸的是, 这个基准testing还不够详细。 有没有任何教程/指南可用于如何运作? 例如, 在Stackoverflow上有一个很大的post,详细介绍了Node,但是我找不到类似的。