有几个类似的问题,但我找不到我的问题的答案。 我想通过域来影响内部应用程序,例如。 域: example.com 内部应用程序: 192.168.0.1 : 8081/ app 这是我的configuration: server { listen 80; server_name example.com; location / { proxy_pass http://192.168.0.1:8081/app; 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; } } 一切都很好,但是当我尝试打开http://example.com时,nginx会暂时redirect到http://example.com/app 。 问题是如何停止redirect? 我想nginx发送HTTP状态200而不是redirect到/应用程序
在我的nginxconfiguration文件中,我有这个location块(修改用于debugging目的): location ~* \.(ico|css|js|gif|jpe?g|png)(\?[0-9]+)?$ { expires 1; log_not_found off; return 515 "Request URI is $request_uri. Caught you"; } 当我从服务器请求这个URI时: /img/signup/be0e1d34fabf2514d49db9baec09f858.png?w=198&h=198&s=9a7d22504c5ae176a936a0f18cccacba 果然,它匹配,我得到了这个机构的515响应: Request URI is /img/signup/be0e1d34fabf2514d49db9baec09f858.png?w=198&h=198&s=9a7d22504c5ae176a936a0f18cccacba. Caught you Request URI is /img/signup/be0e1d34fabf2514d49db9baec09f858.png?w=198&h=198&s=9a7d22504c5ae176a936a0f18cccacba. Caught you 为什么? 正则expression式不匹配,至less不直观(或者它必须以一系列数字或者.png等结尾),也不能在Regex101.com上检查。
首先,我知道在上游服务器上使用SSL并不理想。 在这个时候,我只是不能关掉它,需要离开它(不同的故事,不同的团队)。 我遇到的问题是我的证书设置或NGINX上的SSL终止。 当我点击该网站时,我的浏览器正在抛出错误,因为所提供的SSL证书是其所在上游服务器上的SSL证书(已过期 – 不同的故事,不同的团队)。 我错过了什么使SSL完全终止在NGINX,并成为客户使用的证书? 编辑:修复我可怜的语法。 upstream example { server 1.2.3.4:443; server 4.3.2.1:443; } server { listen 443 ssl; server_name example.org; ssl_certificate /etc/nginx/ssl/example.crt; ssl_certificate_key /etc/nginx/ssl/example.key; location / { proxy_pass https://example/; proxy_set_header Host $host; } ssl_protocols TLSv1.2; ssl_ciphers "AES256+EECDH:AES256+EDH:!aNULL"; ssl_prefer_server_ciphers on; ssl_ecdh_curve secp384r1; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; ssl_session_tickets off; }
我有一个PHP脚本,应接受参数作为URL段如下: wwww.site.com/apps/myapp/index.php/param1/param2 目前我有这个工作没有问题(感谢这个问题 ): www.site.com/index.php/param1/param2 然而,我有麻烦得到它的工作时,index.php是在子目录中。 到目前为止,我在nginx.conf中有这个configuration: location / { root /var/www/html; index index.html index.htm index.php; try_files $uri $uri/ /index.php; } location /apps/myapp/ { root /var/www/html/apps/myapp; index index.html index.php; try_files $uri $uri/ /index.php; } location ~ \.php$ { fastcgi_pass unix:/var/run/php-fpm.sock; fastcgi_index index.php; include /etc/nginx/fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } 在我的日志中,我仍然得到这个错误: FastCGI sent in stderr: "Primary script […]
我想编写一个URL,例如mysite.com/l360/profile/55,然后让NGINX加载mysite.com/l360/home.php?path=profile/55。 不幸的是,这次我不能只是切换到apache2。 所以我必须find一种方法来使NGINX工作。 我现在的问题是,mysite.com/l360加载home.php和mysite.com/l360/home.php正常工作。 当我尝试执行mysite.com/l360/profile时,它会尝试从服务器下载BIN文件。 这是我的configuration: location / { try_files $uri $uri/ $uri.html $uri.php?$query_string; client_max_body_size 50M; client_body_buffer_size 128k; } location /l360 { try_files $uri $uri/ @l360rw; } location @l360rw { return 302 /home.php?path=$uri; } location ~ \.php$ { try_files $uri =404; fastcgi_split_path_info ^(.+\.php)(/.+)$; fastcgi_pass unix:/var/run/php/php5.6-fpm.sock; fastcgi_index home.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_buffers 16 16k; fastcgi_buffer_size 32k; […]
我有一台服务器(Ubuntu 16.04),我已经用nginx设置了openvpn服务器和jenkins。 我只想通过连接到openvpn的设备访问jenkins.domain.com。 这是我的nginx jenkins文件的一部分 server { listen 80; root /var/run/jenkins/war/; access_log /var/log/nginx/jenkins/access.log; error_log /var/log/nginx/jenkins/error.log; # Make site accessible from http://localhost/ server_name jenkins.domain.com www.jenkins.domain.com; location / { allow 10.8.0.0/24; deny all; proxy_pass http://localhost:8080; 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_connect_timeout 150; proxy_send_timeout 100; proxy_read_timeout 100; proxy_buffers 4 32k; client_max_body_size 8m; client_body_buffer_size 128k; […]
我需要这个位置块路由到两个不同的后端端点 location ~* /zones/ 它必须具有使这些重写成功的逻辑: /zones/appinfo.axd >>> /zones/appinfo.axd /zones/api/v2/zones >>> /api/v2/zones 这是我目前的: location ~* /zones/ { proxy_set_header Host $http_host; proxy_set_header Connection ""; rewrite ^ /api/v2/zones break; proxy_pass http://zone_api; } 但是它只能用于第二次重写
我想在PHP 7.0的nginxnetworking服务器上安装Nextcloud,由于某些原因,它不能按预期工作。 Nextcloud错误日志说明如下: “访问脚本”/var/www/cloud/index.php/“已被拒绝(请参阅security.limit_extensions)” 我已经尝试在/etc/php/7.0/fpm/pool.d/www.conf设置security.limit_extensions = .php ,但是根本没有帮助。 我只能通过在php.ini启用cgi.fix_pathinfo来访问Nextcloud,但是我希望它被禁用,因为它可以用来在服务器上执行恶意代码(如果我没有弄错的话)。
我已经configurationNginxcaching来自上游服务器的所有响应,总是返回Cache-Control: public, max-age=1但nginx似乎caching了响应2秒。 怎么来的? 更具体地说,我的上游服务器是一个简单的Express.js(节点)应用程序返回当前时间: app.get('/', function (req, res) { res.setHeader('Cache-Control', 'public, max-age=1'); res.send((new Date()).toISOString()); }); 这是相关的nginxconfiguration: http { proxy_cache_path /data levels=1:2 keys_zone=zuul:10m max_size=10g; … server { location / { proxy_cache zuul; proxy_pass http://zuul; proxy_cache_use_stale updating; proxy_cache_background_update on; } listen 0.0.0.0:80 default_server; } } 然后我在一个循环中curl http://localhost ,希望看到响应(包含node.js看到它的时间戳)每秒都在变化。 而不是每两秒钟更改一次。 就好像Nginx不愿caching响应的时间less于两秒钟,并不尊重上游返回的max-age 。 我如何说服Nginxcaching响应
我在用着 Apache on port 8080 Nginx on 443 Varnish on 80 每当我将新域添加到服务器时,我都不想更改清漆configuration。 我想知道是否有任何正则expression式或variables,使清漆redirect到https所有域。 sub vcl_recv { if (client.ip != "127.0.0.1" && req.http.host ~ "example.com") { set req.http.x-redir = "https://example.com" + req.url; return(synth(850, "")); } } sub vcl_synth { if (resp.status == 850) { set resp.http.Location = req.http.x-redir; set resp.status = 301; return (deliver); } } […]