我试图让Nginx重写传入的请求到我的服务器前缀https://到http:// (这是因为在此站点上使用的CMS强制URI而不是相对path – 本质上打破了整个网站通过使图像,脚本和样式表不可用)。 我目前正在尝试改造由前任设置的现有指令,但是我发现自己受限于我对Nginxconfiguration语法的了解。 代码如下: if ($ssl_protocol = "") { rewrite ^ https://$http_host$request_uri? permanent; } 我目前评论这个代码来防止强制重写http://到https:// ,但是我不能在不破坏站点的情况下反转进程。 以下是我迄今为止所尝试的: if ($ssl_protocol = "https") { rewrite ^ http://$http_host$request_uri? permanent; } 和 # also tried ($ssl_protocol != "") if (!($ssl_protocol = "")) { rewrite ^ http://$http_host$request_uri? permanent; } 第一个似乎没有效果。 发送到客户端的HTML仍会生成未被重写的HTTPS请求。 第二个片段似乎也没有任何影响 – 如果我理解正确(虽然我还是有点惊讶),Nginx不支持布尔否定。 什么是最好的方式(或工作方式)做到这一点? 编辑:我试着从@ NathanC的答案添加代码; 然而,这种无条件的重写会导致redirect循环。 […]
我想通过nginx代理将IMAP客户端请求发送到IMAP后端。 根据mail_auth_http模块,必须使用伪指令auth_http来validation客户端。 但auth_http的目的究竟是什么,为什么authentication过程不能简单地转发到IMAP后端呢? 据我所知, auth_http指向一个authentication脚本,它使用一个自定义的HTTP协议来确定将使用哪个后端等,实际的基于IMAP的authentication被完全跳过。 我对么? 如果有人能举一个实际的例子,我会很感激。
我想要的是第一个变成第二个.. /widget => /widget/index.php /widget/ => /widget/index.php /widget?act=list => /widget/index.php?act=list /widget/?act=list => /widget/index.php?act=list /widget/list => /widget/index.php?act=list /widget/v2?act=list => /widget/v2.php?act=list /widget/v2/?act=list => /widget/v2.php?act=list /widget/v2/list => /widget/v2.php?act=list v2也可以是v45,基本上是“v \ d +” 行为,在这种情况下,“列表”,可以有很多值,更多将被添加。 任何额外的查询参数将只传递$ args,我猜。 基本上URL没有指定版本将去index.php,然后可以决定什么特定的版本文件包括。 我害怕发生的是循环 – 这应该坐下来 location /widget { 对?。 (至于将API的版本放在URL中,我并不想成为RESTful,而且目标受众很less) 关于如何完全在index.php中使用“路由器”完成这些资源也欢迎: – /
我一直在Serverfault寻找几个小时试图解决这个问题,但我找不到解决scheme。 会发生什么是: 我有一个使用wget在我的网站302redirect循环,但不使用浏览器。 在我的nginxconfiguration中,我只有两个301redirect,而不是302 。 我试图禁用WordPress的所有插件没有运气。 什么可能导致这个问题? 下面是我的nginxconfiguration。 wget一些例子: wget elbauldelprogramador.com –2014-10-30 13:10:24– http://elbauldelprogramador.com/ Resolving elbauldelprogramador.com (elbauldelprogramador.com)… Connecting to elbauldelprogramador.com (elbauldelprogramador.com)||:80… connected. HTTP request sent, awaiting response… 302 Moved Temporarily Location: 404 [following] –2014-10-30 13:10:25– http://elbauldelprogramador.com/404 Reusing existing connection to elbauldelprogramador.com:80. HTTP request sent, awaiting response… 302 Moved Temporarily Location: 404 [following] –2014-10-30 13:10:25– http://elbauldelprogramador.com/404 […]
https://www.ssllabs.com/ssltest/analyze.html?d=cablework.co 我不明白为什么一直说“C”。 我禁用了SSLv3。 这是我的configuration文件 server { listen 80; listen 443 ssl spdy; server_name cablework.co; ssl_certificate /etc/nginx/ssl/cablework.co.pem; ssl_certificate_key /etc/nginx/ssl/server.key; return 301 https://www.cablework.co$request_uri; } server { listen 443 ssl spdy; ssl_certificate /etc/nginx/ssl/cablework.co.pem; ssl_certificate_key /etc/nginx/ssl/server.key; ssl_ciphers 'AES256+EECDH:AES256+EDH'; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_session_cache shared:SSL:10m; ssl_stapling on; ssl_stapling_verify on; resolver 8.8.4.4 8.8.4.4 valid=300s; resolver_timeout 10s; ssl_prefer_server_ciphers on; ssl_dhparam /etc/nginx/ssl/dhparam.pem; charset […]
我没有cpanel Debian 7上的nginx 。 我正在调整我的Crontab是这样的: */45 * * * * wget "http://example.com/cron-url.php" >/dev/null 2>&1 上面的cron被403禁止了: –2014-12-10 05:40:01– http://example.com/cron-url.php Connecting to xyz.xx.xx.xxx:80… connected. HTTP request sent, awaiting response… 403 Forbidden 2014-12-10 05:40:01 ERROR 403: Forbidden. 在这里search和谷歌search后,我明白,我的服务器可能阻止wget。 我看了一下我的nginxconfiguration文件,我认为这应该是由于这个: if ($http_user_agent ~* LWP::Simple|BBBike|wget) { return 403; } 对于cron命令,我必须使用它的URL和绝对链接到脚本path不起作用。 现在,如果我需要让cron工作而不被阻塞,我该怎么办? 我想也许我需要从我自己的服务器允许wget,但不知道如何用nginx做到这一点。 有人可以帮我解决这个cron问题吗?
所以我有一个看起来像这样的nginxconfiguration: ## Redirects all HTTP traffic to the HTTPS host server { listen *:80; server_name me.example.com; server_tokens off; return 301 https://me.example.com:443$request_uri; access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; } server { listen *:443 ssl; … } server { listen *:9080; location / { root /var/www; index index.html index.htm; } } 目的是将端口80上的httpstream量指向https(443)。 像冠军一样工作。 问题是,我的端口9080的请求导致我的浏览器切换到HTTPS,然后失败(因为我没有使用9080的SSL,也不想)。 在Safari或Chrome中: http://me.example.com:9080/index.html -> https://me.example.com:9080/index.html : […]
所以,我已经设置FastCGIcaching像这样: location ~ \.php(/.*)?$ { fastcgi_cache RWI; fastcgi_cache_valid 200 60m; set $nocache 0; if ($request_method = POST) { set $nocache 1; } if ($http_cookie ~ (rwi_userid*|rwi_password*)) { set $nocache 1; } if ($request_uri ~* "/(vb/admincp/)") { set $nocache 1; } fastcgi_no_cache $nocache; fastcgi_cache_bypass $nocache; fastcgi_split_path_info ^((?U).+\.php)(/?.+)$; fastcgi_param PATH_INFO $fastcgi_path_info; fastcgi_pass "unix:/var/www/vhosts/system/{domain}/php-fpm.sock"; include /etc/nginx/fastcgi.conf; } 在server{}块的顶部,我有: […]
我不得不在后台运行nginx启动脚本,或者运行时不会返回到shell – 它通过 service nginx start ..或者干脆运行.. /etc/init.d/nginx 直接 我不得不在背景中运行它,然后放弃它.. 运行在Ubuntu 14.04.2,Nginx v 1.4.6上 nginx -V给我们: nginx version: nginx/1.4.6 (Ubuntu) built by gcc 4.8.2 (Ubuntu 4.8.2-19ubuntu1) TLS SNI support enabled configure arguments: –with-cc-opt='-g -O2 -fstack-protector –param=ssp-buffer-size=4 -Wformat -Werror=format-security -D_FORTIFY_SOURCE=2' –with-ld-opt='-Wl,-Bsymbolic-functions -Wl,-z,relro' –prefix=/usr/share/nginx –conf-path=/etc/nginx/nginx.conf –http-log-path=/var/log/nginx/access.log –error-log-path=/var/log/nginx/error.log –lock-path=/var/lock/nginx.lock –pid-path=/run/nginx.pid –http-client-body-temp-path=/var/lib/nginx/body –http-fastcgi-temp-path=/var/lib/nginx/fastcgi –http-proxy-temp-path=/var/lib/nginx/proxy –http-scgi-temp-path=/var/lib/nginx/scgi –http-uwsgi-temp-path=/var/lib/nginx/uwsgi –with-debug –with-pcre-jit –with-ipv6 […]
我的nginx默认configuration文件变得巨大。 我想分割成较小的configuration文件,每个文件只包含一个,最多4个位置,这样我就可以快速启用/禁用它们。 实际的文件如下所示: server { listen 80 default_server; root /var/www/ location /1 { config info…; } location /2 { config info….; } location /abc { proxy_pass…; } location /xyz { fastcgi_pass….; } location /5678ab { config info…; } location /admin { config info….; } 现在,如果我想将每个文件中只有less数几个位置(位置属于同一个文件)分开,那么在不造成混乱的情况下,这将是一个正确的方法(如在每个文件中声明root,因此具有奇怪的path,nginx试图find文件)?