Varnish将在Cache中保存压缩的obj,但是当客户端不支持gzip时.
Varnish如何处理它?它是否也在Cache中保存另一个未压缩的obj,或者解压缩压缩的obj?
我试图在nginx(0.7.67)上为静态文件配置Expires头.静态文件由Golang反向代理提供:
location /rev/ {
proxy_pass http://localhost:8910/;
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;
# I am putting this here, because nginx only uses one location. Is this OK?
location ~* \.(js|css|jpg|jpeg|gif|png|svg|ico|pdf|html|htm)$ {
expires 30d;
}
}
Run Code Online (Sandbox Code Playgroud)
当我这样做时,重启nginx没有错误,但静态文件不再提供.
我已经尝试了以下星座,但它不起作用:
server {
...
location /rev/ {
proxy_pass http://localhost:8910/;
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;
}
location ~* \.(js|css|jpg|jpeg|gif|png|svg|ico|pdf|html|htm)$ {
expires 30d;
}
}
Run Code Online (Sandbox Code Playgroud)
问题:如何为反向代理后面的应用程序上的静态文件应用expires头?
是否可以从另一台服务器运行我的Web应用程序而不是cloud9中提供的服务器?例如:我想用nginx作为后端服务器(i)和/或反向代理(ii)(尝试不同的场景和配置选项)运行不同的应用程序(PHP,Node.js - 不确定什么是可能的) .
编辑:
在这里他们写道:
$ PORT暴露给外部:当您运行侦听环境变量$ PORT中指定的端口的应用程序时,您可以使用http://projectname.username.c9.io URL方案访问此应用程序.代理期望该端口上的服务器是HTTP服务器.不支持其他协议.
这让我相信,如果我在port = $ PORT上启动nginx,它可以通过指定的URL sheme访问 - 任何人都可以确认吗?也许有人试过这个并且可以分享一些节省时间的提示.谢谢.
我在下面给出了/etc/nginx/sites-available/default文件的摘要
server {
listen 443 ssl;
server_name example.com;
root /var/www/html;
index index.php index.html;
location / {
try_files $uri $uri/ = 404;
}
location /rproxy/ {
proxy_pass https://example.org:8144/;
}
location ~ \.php$ {
try_files $uri = 404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
....
}
Run Code Online (Sandbox Code Playgroud)
该example.org:8144服务器
有文件和
index.php - 返回hello Worldbonjour.php - 返回bonjour现在问题是:
如果我浏览https://example.com/rproxy它,请立即返回hello world - 预期结果.
但是,如果我浏览https://example.com/rproxy/bonjour.php(甚至https://example.com/rproxy/index.php)我得到一个404 error.
我明白这里发生了什么.我的Nginx配置导致Nginx的example.com实例尝试查找*.php本地(即打开example.com)的所有文件,当我正在寻找的文件实际打开时,该文件失败example.org:8144.
我想有一种相对简单的方法可以判断Nginx何时不尝试执行PHP …
我试图配置Apache以不同方式对待应用程序的某些端点。
我需要/ api,/ appname和/ admin转发到同一主机上的单独Tomcat实例,显然是在不同的端口上运行。
Apache正在监听443(SSL)。
查看Apache的文档,我看到一些示例,其中mod_rewrite用于类似的任务,而不是实际的用例。
只有端口80和443(80重定向到443)向外部开放,因此其他端口仅是内部端口……我们将其称为2001、3001和4001。
编辑:附录:我正在使用apache 2.2,目前没有计划更新到2.4.x。
Nginx 1.9.5(Linux Centos7)-> MS IIS 8.5因此,我尝试将nginx用作IIS的客户端反向代理,其中需要在IIS级别进行客户端证书身份验证。nginx:443->> IIS:443+客户端证书身份验证。
示例位置代理通过也这里是我尝试的注释命令。
location ^~ /test/ {
#proxy_buffering off;
#proxy_http_version 1.0;
#proxy_request_buffering off;
#proxy_set_header Connection "Keep-Alive";
#proxy_set_header X-SSL-CERT $ssl_client_cert;
# proxy_ssl_name domain.lv;
#proxy_ssl_trusted_certificate /etc/nginx/ssl/root/CA.pem;
#proxy_ssl_verify_depth 2;
proxy_set_header HOST domain.com;
proxy_ssl_certificate /etc/nginx/ssl/test.pem;
proxy_ssl_certificate_key /etc/nginx/ssl/test_key.pem;
proxy_ssl_verify off;
proxy_pass https://10.2.4.101/;
}
Run Code Online (Sandbox Code Playgroud)
在IIS上很简单。
测试我得到什么:
错误:Nginx端:* 4622上游超时(110:连接超时),同时从上游IIS端读取响应标头:500 0 64 119971
所以我希望有人能知道为什么?
编辑1.还尝试从其他服务器使用Nginx 1.8,没有帮助。
proxy_ssl_verify off;
proxy_ssl_certificate /etc/nginx/ssl/test/test.pem;
proxy_ssl_certificate_key /etc/nginx/ssl/test/test_key.pem;
proxy_pass https://domain.com;
Run Code Online (Sandbox Code Playgroud)
2.尝试与Apache 2.4相同
SSLProxyEngine On
SSLProxyVerify none
SSLProxyCheckPeerCN off
SSLProxyCheckPeerName off
SSLProxyCheckPeerExpire off …Run Code Online (Sandbox Code Playgroud) 我想我的问题的答案将非常简单,但遗憾的是我自己无法弄明白!
我在服务器A(192.168.1.1)上运行的Nginx充当服务器B(192.168.1.2)上的WebSocket服务器的反向代理.最后一台服务器正在侦听端口1234并有2条路径,因此我们可以连接到以下地址:
ws://192.168.1.2:1234/path1
ws://192.168.1.2:1234/path2
Run Code Online (Sandbox Code Playgroud)
通过添加以下配置,我已经能够通过代理(ws://192.168.1.1/websocket/path1)成功连接到Path1:
location /websocket/path1 {
proxy_pass http://192.168.1.2:1234/path1;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
Run Code Online (Sandbox Code Playgroud)
现在我想使它足够通用以匹配第二条路径(而不是为path2创建类似的规则),我尝试了类似的东西:
location /websocket {
proxy_pass http://192.168.1.2:1234;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
}
Run Code Online (Sandbox Code Playgroud)
但是这样我无法访问WebSocket.
你知道什么是错的吗?
非常感谢您的宝贵时间!
如何向受NTLM保护的网站(如TeamFoundation和SharePoint)代理请求?我一直收到401身份验证错误.
我在理解反向代理(即使用proxy_pass指令和给定的上游服务器)和301永久重定向之间的区别时遇到了一些困难.它们如何相似/不同?
反向代理
upstream backend {
server backend1.example.com weight=5;
server backend2.example.com:8080;
}
server {
location / {
proxy_pass http://backend;
}
}
Run Code Online (Sandbox Code Playgroud)
HHTP重定向
Apache示例:http://www.inmotionhosting.com/support/website/htaccess/redirect-without-changing-url
NGINX示例:
server {
listen 80;
server_name domain1.com;
return 301 $scheme://domain2.com$request_uri;
}
Run Code Online (Sandbox Code Playgroud)
因此,似乎两种方法与最终用户的观点没有区别.我想确保有效的带宽使用,同时使用SSL.目前,应用服务器使用自己的自签名SSL证书和Nginx.将用户从标准Web托管公司(hostgator,godaddy等)托管的网站重定向到单独的服务器应用服务器的建议方法是什么?
Traefik完全忽略了"标签"配置.
按照Traefik的主要文档页面,我们可以简单地做到:
#docker-compose.yml
version: '3'
services:
traefik:
image: traefik # The official Traefik docker image
command: --api --docker # Enables the web UI and tells Træfik to listen to docker
ports:
- "80:80" # The HTTP port
- "8080:8080" # The Web UI (enabled by --api)
volumes:
- ./docker.sock:/var/run/docker.sock # So that Traefik can listen to the Docker events
whoami:
image: emilevauge/whoami # A container that exposes an API to show its IP address
labels:
- "traefik.frontend.rule=Host:whoami.docker.localhost"
Run Code Online (Sandbox Code Playgroud)
然后,运行docker-compose就足够了(没有traefik.toml文件): …
reverse-proxy ×10
nginx ×6
apache ×2
php ×2
ssl ×2
cloud9-ide ×1
docker ×1
haproxy ×1
http ×1
iis ×1
mod-proxy ×1
mod-rewrite ×1
redirect ×1
sharepoint ×1
tfs ×1
tomcat ×1
traefik ×1
varnish ×1
varnish-vcl ×1
websocket ×1