我有一个nginx服务器提供受保护的资源。 我想要做的最后一件事是pipe理密码重置请求,所以我正在寻找与谷歌login 。 他们有PHP,Java,JavaScript等的示例,但不适用于Apache或nginx。 我如何configurationnginx以使用Googlefunctionlogin交换基本身份validation? 后面的一些代理系统依赖于%REMOTE_USER%variables,所以我需要保留一个。 帮助表示赞赏。 更新澄清:我有一组服务(一个tomcat,一个node.js,一个couchdb,一个vert.x,一些python),坐在networking服务器后面,这可能会或可能不授权用户与他们进行交互。 他们都有共同点,他们可以从networking层接收身份信息。 所以我在web层做了什么:指定 – “只有authentication的用户”(这是授权设置,我“重复使用”来触发authentication机制)。 一旦用户被authentication,该身份信息被传递。 有关基本身份validation和CouchDB的示例,请查看此博客条目 。 我可以在nginx中做同样的事情,但是这里的任务是使用与外部提供者build立的身份来保密密码 。
我知道这是一个非常不好的问题,但我找不到任何解决scheme,尽pipe发现问题微不足道。 我有一个Django应用程序与gunicorn部署。 nginx服务器使用以下URL提供静态文件: myserver.com/static/admin/css/base.css 。 然而,我的django应用程序继续寻找在myserver.com:8001/static/admin/css/base.css的静态文件,显然是失败的(404)。 我不知道如何解决这个问题。 这是一个Django的或Nginx的问题? 这是我的nginxconfiguration文件: server { server_name myserver.com; access_log off; location /static/ { alias /home/myproject/static/; } location / { proxy_pass http://127.0.0.1:8001; proxy_set_header X-Forwarded-Host $server_name; proxy_set_header X-Real-IP $remote_addr; add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"'; } } 谢谢您的帮助 !
我想将我的API(及其文档)的v1.2公开给中国的用户。 父网站mysite.mycompany.com被阻止,但1.2.3.4不是,所以我在这个地址build立一个反向代理,他们可以用来访问我的服务。 我已经configuration了一个Nginx来将http://mysite.mycompany.com代理反向到http://1.2.3.4 该代理在Firefox和IE浏览器中运行良好,但在Chrome浏览器中不起作用。 login是使用cookie进行pipe理的,但Chrome会忽略login时代理发送的Set-Cookie头,我不明白为什么。 这可以防止Chrome用户login。 父站点对login请求(其中Set-Cookie成功并且login成功)的响应标头是 HTTP/1.1 302 Found Cache-Control: no-cache, must-revalidate, post-check=0, pre-check=0 Content-Type: text/html; charset=UTF-8 Date: Tue, 12 Aug 2014 18:16:57 GMT ETag: "1407867417" Expires: Sun, 19 Nov 1978 05:00:00 GMT Last-Modified: Tue, 12 Aug 2014 18:16:57 +0000 Location: http://mysite.mycompany.com/user/me/apps Server: Apache X-Powered-By: PHP/5.3.15 Content-Length: 0 Connection: Keep-Alive Set-Cookie: SESS25fe1d0b3b7239f403e22223da0614cf=Oo-PXr4XYQCFUKYUyZgX3UJpWADAhF_q7Xf-8gko3BU; expires=Thu, 04-Sep-2014 […]
在nginx位置指令中,我如何匹配s3的url。 例如,错误的url是: http://example.com/https://s3.amazonaws.com/mybucket/logo.jpg?1404251306 从日志,我可以看到nginx能够从这个url服务请求,并返回一个404。 xx.xx.xx.xx – – [15/Aug/2014:12:38:04 +0000] "GET /https://s3.amazonaws.com/mybucket/logo.jpg HTTP/1.1" 404 151 "-" "Mo 有了这个,我想匹配这个url,将请求代理到s3并返回logo.jpg 。 我已经想出了这样的事情: location ~* ^/https/(.*) { set $s3_host 's3.amazonaws.com'; set $s3_bucket 'mybucket'; proxy_set_header Host $s3_host; proxy_set_header Authorization ''; proxy_hide_header x-amz-id-2; proxy_hide_header x-amz-request-id; proxy_hide_header Set-Cookie; proxy_ignore_headers "Set-Cookie"; proxy_buffering off; proxy_intercept_errors on; resolver 8.8.8.8 valid=300s; resolver_timeout 10s; proxy_pass http://$1; } […]
在说ngx_http_limit_req_module的文档中 客户端IP地址是一个关键。 请注意,不是$ remote_addr,$ binary_remote_addrvariables在这里使用,它允许将状态大小减小到64字节。 一兆字节的区域可以保持约一万六千字节的状态。 如果区域存储耗尽,服务器将返回503(服务暂时不可用)错误到所有进一步的请求。 不幸的是,它没有说如果你不使用IP地址的二进制版本将有多大。 我需要使用$http_x_forwarded_for作为关键字,在这种情况下每个状态有多大?
我正在尝试将nginx安装扩展到最好的能力。 我正在运行一个具有6个worker_processes(6个核心)和5个后端服务器的nginx实例,每个服务器由10个工人组成的uwsgi设置组成。 (共有50名工人)。 不过,我尝试使用不同参数(使用ab )进行全连接和并发连接的任何基准testing似乎都以约1000个请求/秒的速度出现。 我已经禁用所有的日志loggingnginx和uwsgi(为了避免由于磁盘问题而变慢)。 我正在testing一个仅仅发送{'status':'ok'}的Flask python应用程序。 没有数据库访问,没有计算,没有。 nginxconfiguration的相关部分如下所示: user www-data; worker_processes 6; worker_rlimit_nofile 100000; pid /var/run/nginx.pid; events { use epoll; worker_connections 2048; multi_accept on; } http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; […]
我想在try_files的第一个文件被find时设置一个自定义的“X-Cache-Status”头文件 ,但是当其他文件匹配的时候没有。 什么是最好的方法来做到这一点? server { location / { try_files /cache/${host}${cache_uri}_index.html $uri $uri/ /index.php?q=$uri&$args; } }
我正在尝试使用来自源代码的Pagespeed编译Nginx,而且我试图解决在添加configuration设置时看到的not found错误。 这是我的configuration设置: 我正在使用CentOS 7 – 64位 configuration设置: sudo ./configure –add-module=/nginx-compile/modules/ngx_pagespeed-release-1.9.32.1-beta \ –prefix=/etc/nginx \ –sbin-path=/usr/sbin/nginx \ –conf-path=/etc/nginx/nginx.conf \ –error-log-path=/var/log/nginx/error.log \ –http-log-path=/var/log/nginx/access.log \ –pid-path=/var/run/nginx.pid \ –lock-path=/var/run/nginx.lock \ –http-client-body-temp-path=/var/cache/nginx/client_temp \ –http-proxy-temp-path=/var/cache/nginx/proxy_temp \ –http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp \ –http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp \ –http-scgi-temp-path=/var/cache/nginx/scgi_temp \ –with-http_ssl_module \ –with-http_realip_module \ –with-http_addition_module \ –with-http_sub_module \ –with-http_dav_module \ –with-http_flv_module \ –with-http_mp4_module \ –with-http_gunzip_module \ –with-http_gzip_static_module \ –with-http_random_index_module […]
我与我们的客户有一些问题,报告我们的一些网页速度很慢。 这可能是由于许多原因,但我特别要logging每个页面的执行时间,而不必在每个PHP脚本的页眉和页脚中添加内容。 有什么select? (如果它有所不同,我们正在运行Nginx Web服务器和PHP-FPM)
我试图用反向代理访问另一台服务器。 “主”服务器在mydomain.com后面,我想通过使用mydomain.com/test访问第二个。 目前只是mydomain.com/test的作品。 但是,如果我尝试访问mydomain.com/test/myfiles,我被redirect到mydomain.com/myfiles,因为这个URL的目标是“主”服务器,所以不存在404找不到。 我尝试了多个与proxy_redirect的东西,重写但没有任何工作。 server { listen 80; index index.php index.html index.htm; root /path/to/content; server_name localhost mydomain.com; location / { try_files $uri $uri/ =404; #/index.html; } location /test/ { proxy_pass http://192.168.1.202/; proxy_set_header Host $host; } location ~ \.php$ { fastcgi_pass unix:/var/run/php5-fpm.sock; fastcgi_index index.php; include fastcgi_params; } } curl -I "http://192.168.1.202" -H "Host: mydomain.com"在主服务器上给出: HTTP/1.1 […]