我已经有一个正在运行的 https 站点。我的以下配置适用于 webmin。除了当我登录时,网址重写了它旁边的端口号 10000,因此找不到错误服务器。任何人都可以帮我纠正这个吗?
server {
server_name webmin.example.com;
listen 443;
ssl on;
ssl_certificate /etc/webmin/miniserv.pem;
ssl_certificate_key /etc/webmin/miniserv.pem;
access_log off;
error_log off;
location /RequestDenied {
return 418;
}
location / {
proxy_pass https://127.0.0.1:10000;
proxy_redirect off;
#Proxy Settings
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_max_temp_file_size 0;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 128k;
proxy_buffers 32 32k;
proxy_busy_buffers_size 256k;
proxy_temp_file_write_size 256k;
}
}
Run Code Online (Sandbox Code Playgroud) 我有一个 NGINX 设置了反向代理和缓存(仅在很短的时间内缓存多个请求)。后端 nginx 调用在本地运行(反向代理地址为 localhost:8092)。后端有时需要重新启动,这会使其离线约 2-3 秒。目前,nginx 这次服务的是 502。我宁愿推迟那个时间的请求。是否可以将 nginx 配置为在出现 502 时等待并定期重试?
我知道这不是解决此问题的最干净的方法,但这不是生产系统,因此这(如果可能)似乎是最简单的解决方案。
系统运行 Ubuntu 16.04LTS 和 nginx 1.10.3
我正在使用 nginx 的 $geoip_country_code 模块根据 IP 重定向用户。我的配置代码如下所示-
server {
listen 80;
gzip on;
server_name example.com;
root html/example;
location / {
index index.html;
try_files /$geoip_country_code/index.html /index.html;
}
location ~* \.(gif|jpg|jpeg|png|js|css)$ { }
}
Run Code Online (Sandbox Code Playgroud)
想法是根据我已本地化的国家/地区重定向用户,否则用户将转到默认索引,即其他人通用的索引。当我在我的国家/地区的浏览器中打开它时,它可以完美地工作,因为我已经对其进行了本地化。但当从不同的国家/地区打开时,它会显示内部服务器错误。它不会进入默认索引页。
有人可以指出我做错了什么吗?
当我尝试使用此配置启动 nginx 服务器时,出现错误
nginx: [emerg] no ssl_client_certificate for ssl_client_verify
Run Code Online (Sandbox Code Playgroud)
我的配置看起来像
# HTTPS server
server {
listen 4443;
server_name localhost;
ssl on;
ssl_certificate /home/user/conf/ssl/server.pem;
ssl_certificate_key /home/user/conf/ssl/server.pem;
ssl_protocols TLSv1.2;
ssl_verify_client optional;
ssl_trusted_certificate /home/user/ssl/certs/certificate_bundle.pem;
include conf.d/api_proxy.conf;
}
Run Code Online (Sandbox Code Playgroud)
根据错误,我应该使用ssl_client_certificate指令,但根据文档,如果我不想将证书列表发送给客户端,我应该使用ssl_trusted_certificate.
http://nginx.org/en/docs/http/ngx_http_ssl_module.html#ssl_client_certificate
有人可以帮我弄清楚我错过了什么吗?
我已经研究了RoR 5.0.0 ActionCable wss WebSocket握手的答案:意外的响应代码:301,但不适用于我的情况。
我使用nginx代理作为在docker-containers中运行的多个Web服务器的前端。我使用来自https://github.com/jwilder/nginx-proxy的nginx-config-template
现在在我的docker-container中,我有另一个具有以下配置的nginx:
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
upstream websocket {
server my-websocket-docker-container:8080;
}
server {
root /src/html;
location /websocket/ {
resolver 127.0.0.11 ipv6=off;
proxy_pass http://websocket;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
}
location / {
# try to serve file directly, fallback to index.php
try_files $uri /index.php$is_args$args;
}
...
}
Run Code Online (Sandbox Code Playgroud)
当尝试连接到wss://example.com/websocket时,出现关于意外响应代码301的上述错误。当我手动卷曲websocket-url时,我可以看到nginx响应告诉我“ 301永久移动”。但为什么?这是哪里来的?
有人可以帮忙吗?谢谢!
如果上游启动(max-age 1)绕过缓存并在关闭时使用缓存(proxy_cache_use_stale),我创建了以下配置:
proxy_cache_path /app/cache/ui levels=1:2 keys_zone=ui:10m max_size=1g inactive=30d;
server {
...
location /app/ui/config.json {
proxy_cache ui;
proxy_cache_valid 1d;
proxy_ignore_headers Expires;
proxy_hide_header Expires;
proxy_hide_header Cache-Control;
add_header Cache-Control "max-age=1, public";
proxy_cache_use_stale error timeout http_500 http_502 http_503 http_504;
add_header X-Cache-Status $upstream_cache_status;
add_header X-Cache-Date $upstream_http_date;
proxy_pass http://app/config.json;
}
}
Run Code Online (Sandbox Code Playgroud)
但是当上游关闭并且客户端仅获得 504 Gateway Timeout 时不使用缓存。我已经阅读了以下文章:
https://nginx.org/ru/docs/http/ngx_http_proxy_module.html#proxy_cache_use_stale
如何配置 NginX 仅在后端关闭时才提供缓存内容(5xx 响应代码)?
https://serverfault.com/questions/752838/nginx-use-proxy-cache-if-backend-is-down
它不像我期望的那样工作。任何帮助表示赞赏。
caching nginx nginx-location nginx-reverse-proxy nginx-config
我有一个 NGINX 服务器作为反向代理运行。代理适用于 Windows 主机,但是我有一个 owncloud 服务器,代理会将 url 重新写入内部主机名或 IP 地址。ex(我输入 cloud.example.com 并且我的网址栏将更改为 10.1.1.19,这是无法通过 wan 解析的
我检查了 DNS 记录并确保 NGINX 可以解析主机名。还尝试将 http 流量转发到云服务器以确保使用域名不是问题。
server {
listen 80;
listen [::]:80;
server_name example.com;
location / {
proxy_pass http://10.1.1.16:80/;
}
}
server {
listen 80;
listen [::]:80;
server_name cloud.example.com;
location / {
proxy_pass http://10.1.1.19:80/;
}
}
server {
listen 80;
listen [::]:80;
server_name remote.example.com;
location / {
proxy_pass http://10.1.1.17:80/;
}
}
Run Code Online (Sandbox Code Playgroud)
我只需要 NGINX 作为“cloud.example.com”的代理运行而不是重写 URL
我在 NGINX入口控制器后面的 Kubernetes 1.13 集群中托管一个 Web 应用程序。的Ingress指定path: /my-webapp/?(.*)和annotations:
{ nginx.ingress.kubernetes.io/rewrite-target: /$1 }使得所述web应用可以从在集群外部够到http://my-cluster/my-webapp。(入口控制器公开为my-cluster.)
剩下的一个问题是,webapp 包含引用例如 CGI 脚本和 CSS 样式表的“相对”URL。例如,<link rel="stylesheet" type="text/css" href="/my-stylesheet.css" />当前未加载样式表。我认为这是因为浏览器在错误的 URL 上请求它(http://my-cluster/my-webapp/my-stylesheet.css应该是正确的)并且需要更多的注释。
这种情况下正确的配置是什么?
UPDATE检查器显示浏览器当前从 URL 请求样式表http://my-cluster/my-stylesheet.css,这确实是错误的,需要修复。
更新 这看起来像是一个与 NGINX 反向代理相关的问题,而不是 Kubernetes NGINX 入口控制器。我想知道建议的食谱是否以及如何在这种特殊情况下也适用。首先,我尝试切换到引用样式表的相对 URL(根据已接受答案中的配方 One),但这到目前为止还没有奏效:
,尽管它显示,但<link rel="stylesheet" type="text/css" href="my-stylesheet.css" />浏览器显然仍在尝试从 获取样式表在 URL 栏中,检查器报告的 URL 与.http://my-cluster/my-stylesheet.csshttp://my-cluster/my-webappbaseURI
我目前正在树莓派上使用dialogflow api。使用 grpc 调用 StreamingDetectIntent 方法时一切正常。我必须在我的产品上使用多个 api,因此,我尝试在它们前面放置一个反向代理。这样,我只能调用一个地址,我正在使用 nginx 将我的 GRPC 请求反向代理到 google api。调用简单方法时没有问题,但是当调用像 StreamingDetectIntent 这样的流方法时,我在请求期间收到错误。
Dialogflow 获取来自客户端的音频流量没有问题,但获取请求的最后部分(下游流量)时遇到问题。
这是我的客户给我的错误:
grpc._channel._Rendezvous: <_Rendezvous of RPC that terminated with:
status = StatusCode.INTERNAL
details = "Received RST_STREAM with error code 2"
debug_error_string = "{"created":"@1567173815.816362297","description":"Error received from peer ipv4:163.172.143.250:443","file":"src/core/lib/surface/call.cc","file_line":1041,"grpc_message":"Received RST_STREAM with error code 2","grpc_status":13}"
>
Run Code Online (Sandbox Code Playgroud)
我可以在 Nginx 日志中看到错误:
upstream sent frame for closed stream 1 while reading upstream, client: ..., server: exemple.com, request: "POST /google.cloud.dialogflow.v2beta1.Sessions/StreamingDetectIntent HTTP/2.0", upstream: "grpcs://...:443", host: "example.com:443"
Run Code Online (Sandbox Code Playgroud)
我尝试将 grpc_buffer_size 参数增加到大值,但没有成功。
这是我当前的 Nginx 配置: …
问题:Nginx 服务器正在缓冲服务器发送的事件(SSE)。
设置:节点 v12.13.1、Nginx 1.16.1、Chrome v80
场景:我尝试关闭缓冲,proxy_buffering off;甚至添加"X-Accel-Buffering": "no"到服务器响应标头中,但 nginx 仍在缓冲所有 SSE。如果我关闭节点服务器或重新启动 nginx 服务器,则所有 SSE 消息都会批量传递到客户端。我尝试了很多,但不知道我失踪了。
Nginx 配置文件:
events {
worker_connections 1024;
}
http {
include mime.types;
sendfile on;
keepalive_timeout 65;
server {
listen 4200;
server_name localhost;
location / {
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
proxy_pass http://localhost:8700;
}
}
}
Run Code Online (Sandbox Code Playgroud)
节点服务器:
var express = require('express');
var app = express();
var template =
`<!DOCTYPE html> <html> <body>
<script type="text/javascript">
var source …Run Code Online (Sandbox Code Playgroud) nginx ×8
nginx-config ×2
caching ×1
devops ×1
grpc ×1
nginx-status ×1
proxy ×1
webmin ×1
websocket ×1