Articles of proxypass

nginx proxy_pass将两个端口转换为子文件夹

所以我有我的最后一个“反向代理”问题固定关于“映射”一个端口到子文件夹再次感谢这个真棒社区。 我已经能够使用这个解决scheme了一段时间,但现在我面临一个新的问题。 情况是: 有一个网页设置(使用nginx)与此urlhttp://test.domain.com:8042/view.html 。 我需要各种各样的原因,这个端口变成一个子文件夹,并实现它(帮助),并获得http://test.domain.com/view/view.html 。 这个proxy_pass是: location ~/view(.*)$ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host:$server_port; proxy_pass http://test.domain.com:8042$1; 这个很棒。 我可以通过http://test.domain.com/view/view.html访问该页面。 这个页面上有几个websocket,其中一个也有8042端口。这个工作正常。 但是,其他websockets有不同的端口,例如8159.我已经添加了一个相应的proxy_pass到nginxconfiguration: location ~/cantrace(.*)$ { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host:$server_port; proxy_pass http://test.domain.com:8159$1; 从Javascript这个websocket被称为通过 my_websocket = new WebSocket('ws://test.domain.com/cantrace/ws'); 但是这不起作用。 也没有 my_websocket = new WebSocket('ws://test.domain.com/view/cantrace/ws'); 但是,工作是什么? http://test.domain.com:8042/view.html 然后加载view.html上的其他websocket my_websocket […]

NGINX在使用上行时没有响应

我试图通过nginx来平衡一个web应用程序,它可以正常工作,我的web应用程序会调用带有子path的服务。 例如它的工作 http://example.com/luna/ 但不是 http://example.com/luna/sales 我的nginx.conf user nobody; worker_processes auto; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; map $http_upgrade $connection_upgrade { default upgrade; '' close; } upstream lunaups { server myhostserver1.com:8080; server myhostserver2.com:8080; } server { listen 80; server_name example.com; proxy_pass_header Server; location = / { rewrite […]

身份validation适用于文件系统,而不是反向代理

我有一台运行OS X Server 5.1.7的Mac Mini。 我有一个服务运行本地访问通过http://127.0.0.1:3000/ask (无需身份validation),我想使其可用于外部,但使用OS X服务器目录进行身份validation。 因此,在网站部分,我创build了一个名为intranet.mydomain.com的新网站,只有“Intranet用户”(我创build的一个组)才能访问。 这样做后,我尝试访问https://intranet.mydomain.com ,它要求input用户名和密码,并且与“Intranet用户”一部分用户的凭证一起使用。 现在,要设置反向代理,我转到该文件 /Library/Server/Web/Config/apache2/sites/0000_127.0.0.1_34543_intranet.mydomain.com.conf 并添加以下内容: ProxyPass /询问http://127.0.0.1:3000/ask ProxyPassReverse /询问http://127.0.0.1:3000/ask Directory节点之后。 现在,当访问https://intranet.mydomain.com/ask时 ,我到达了内部服务,但是没有请求authentication。 这应该是好的,我相信,因为在XMLconfiguration中只有Directory节点configuration了authentication: <Directory "/Library/Server/Web/Data/Sites/intranet.mydomain.com"> Options All -Indexes -ExecCGI -Includes +MultiViews AllowOverride None <IfModule mod_dav.c> DAV Off </IfModule> <IfDefine !WEBSERVICE_ON> Require all denied ErrorDocument 403 /customerror/websitesoff403.html </IfDefine> AuthType Digest AuthName "Realm ID 75040558" <Limit PUT DELETE […]

具有客户端证书性能的apache httpd ProxyPass

我们在这里有一个在wildfly 9上运行的WebService。Web服务只能通过ssl(https)使用,并且需要客户端证书。 如果我们在我们的testing用例中更改wildfly将直接与客户进行通信的wildflyconfiguration(意味着wildfly将处理https连接,并且还将检查客户端证书),则一个客户端可以每秒发出12到15个请求(包括得到服务器的答案)。 但是,如果我们在wildfly前放置一个apache httpd(在CentOS6上的V2.2)代理(然后它将处理https SSL的东西,并将检查客户端证书),然后客户端可以(在同一个testing用例中)只有2到5每秒请求数。 httpd代理的configuration是: Listen 58443 NameVirtualHost *:58443 <VirtualHost *:58443> # server SSL settings SSLEngine on SSLProtocol all -SSLv2 -SSLv3 SSLHonorCipherOrder On SSLCipherSuite ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AES:RSA+3DES:!ADH:!AECDH:!MD5:!DSS # Server Certificate: SSLCertificateFile /etc/letsencrypt/live/mydomain.de/cert.pem # Server Private Key: SSLCertificateKeyFile /etc/letsencrypt/live/mydomain.de/privkey.pem # Server Certificate Chain: SSLCertificateChainFile /etc/letsencrypt/live/mydomain.de/chain.pem Header always set Strict-Transport-Security "max-age=315360000" # Client certifacte authentication # Certificate […]

Locationmatch不起作用

我有这2个LocationMatch指令 <LocationMatch "^.*system/app_dev\.php(.*)$"> ProxyPass fcgi://127.0.0.1:9998/var/www/example.com/trunk/system/web/app_dev.php </LocationMatch> <LocationMatch "^.*system(.*)$"> ProxyPass fcgi://127.0.0.1:9998/var/www/example.com/trunk/system/web/app.php </LocationMatch> 我预计 http://example.com/system/app_dev.php/files/abc 由第一条规则来匹配 http://example.com/system/files/abc 由第二条规则。 但在我的情况下,两者都是由第二条规则相匹配。 这是在Apache 2.4上

如果远程path不通过proxy_pass存在,则服务特定的远程path

我已经解决了这个差不多半天了。 🙁 在我的笔记本电脑上运行的Nginx上,我不使用proxy_pass,这个try文件工作的很好。 我写的JavaScript web应用程序在加载页面时执行客户端路由。 但是,如果网页被刷新,则是接收请求的服务器。 我在我的笔记本电脑上运行我的Nginxconfiguration location /viewer { try_files $uri /viewer/index.html; } 使用上面的configuration,如果我请求在我的文件系统上不存在的http:// localhost / viewer / getservice ,我将与/viewer/index.html一起提供服务。 这工作很好! 但是,我们在工作中有不同的configuration。 我们所有的静态文件/ html页面都存储在上游的S3存储桶中。 这是我们的工作configuration location /viewer { proxy_pass http://s3-bucket-server/viewer; add_header 'Access-Control-Allow-Credentials' 'true'; add_header 'Access-Control-Allow-Origin' $cors_header; add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS'; add_header 'Access-Control-Allow-Headers' 'DNT,Keep-Alive,User-Agent,Origin,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type'; } 当我像这样访问它时,上面的configuration很好用, http://internal-app.docs.svr/viewer 。 我可以点击我们的左侧导航,这改变了客户端的位置path http://internal-app.docs.svr/viewer/settings http://internal-app.docs.svr/viewer/docs http://internal-app.docs.svr/viewer/permissions etc 但是,如果假设我在http://internal-app.docs.svr/viewer/permissions并且单击了浏览器,通常会发生的情况是,它会在我们的Web服务器internal- […]

nginx proxy_pass仅适用于根path

我想将nginx设置为apache的反向代理。 我在端口8080上有apache。它只适用于根path,例如https://www.example.com ,但它不适用于https://www.example.com/index.html location / { try_files $uri $uri/ /index.php; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; proxy_set_header Host $host; proxy_pass http://127.0.0.1:8080; } 我尝试join斜线地址,如http://127.0.0.1:8080/,但后来我得到configuration错误。 就像这里: https : //stackoverflow.com/questions/21662940/nginx-proxy-pass-cannot-have-uri-part-in-location我试图使用重写,但我不知道该重写什么是。

Nginx代理传递给本地主机Gunicorn意外返回50x错误

我有一个非常基本的设置与nginx安装在运行在gunicorn服务器上的django应用程序。 gunicorn conf很简单,下面是: exec gunicorn myapp.wsgi:application \ –workers 5 –reload 我已经设置了nginx服务器,将默认服务器上的所有传入stream量proxy_pass设置为127.0.0.1:8000。 但是,当我到服务器的IP地址,我看到默认的nginx 404屏幕。 所以我假设stream量是由nginx服务器传递的代理,但不知何故没有正确路由,并没有回应,这迫使nginx返回404。我究竟是在这里做gunicorn或nginxconfiguration错误? 作为参考,下面是我的完整的nginx.conf文件: user nginx; worker_processes auto; error_log /var/log/nginx/error.log; pid /run/nginx.pid; # Load dynamic modules. See /usr/share/nginx/README.dynamic. include /usr/share/nginx/modules/*.conf; events { worker_connections 1024; } http { log_format main '$remote_addr – $remote_user [$time_local] "$request" ' '$status $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for"'; access_log /var/log/nginx/access.log main; […]

nginx代理传递给supervisord

我正在尝试在http://example.com/supervisor上提供supervisord网页界面 尝试了好几个小时后,我用正斜杠( http://example.com/supervisor/ )正确工作。 我得到它显示没有太斜杠,但没有图像/ CSS等的作品。 我是nginx的新手,所以我猜我的重写规则有些问题。 第一次重写是我试图添加一个结尾的斜杠。 supervisord.conf [unix_http_server] file = /tmp/supervisor.sock ; (the path to the socket file) chmod=0700 ; socket file mode (default 0700) nginx.conf location ~* ^/supervisor/? { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_x_host; proxy_set_header X-NginX-Proxy true; rewrite ^(.*[^/])$ $1/; rewrite /supervisor/(.*) /$1 break; proxy_pass http://unix:/tmp/supervisor.sock:; proxy_redirect off; […]

nginx代理域到url,显示旧域

我有两个子域,我想以下面的方式链接: https://suba.example.org/ : https://suba.example.org/是我的主要子域, https://subb.example.org/是我的辅助子域。 在suba我有一个服务器运行一个Web应用程序,subb只用于redirect。 suba上的这个服务器有一个url,可以叫它https://suba.example.org/foo.php/bar 。 我想要的只是,当我在浏览器中inputhttps://subb.example.org/ ,会显示https://suba.example.org/foo.php/bar的内容, 但是 URL需要说明https://subb.example.org/ 。 截至目前,它将正确显示https://suba.example.org/foo.php/bar的内容,但浏览器将显示内容的URL而不是https://subb.example.org/ 。 我重新启动了nginx-server几次,并使用隐身窗口,确保浏览器不会caching任何数据。 发生什么事是: 我在桌面上的Chrome隐身窗口中打开了https://subb.example.org/ :它将显示https://suba.example.org/foo.php/bar的正确输出, 但会显示https://suba.example.org/foo.php/bar在URL栏中 我在任何其他浏览器/机器(包括另一台机器上的Chrome隐身窗口)上打开了https://subb.example.org/ :它将显示https://suba.example.org/foo.php/bar的内容https://suba.example.org/foo.php/bar https://subb.example.org URL栏, 但只有文本,没有CSS或图片。 像80年代的网站。 在点击之前input: /imgs/Q5mgx.png : /imgs/Q5mgx.png 发生了什么: /imgs/CfHM1.png : /imgs/CfHM1.png 应该发生什么: /imgs/5OxQ4.png : /imgs/5OxQ4.png 任何帮助表示赞赏。 附件是我的nginx site-config的subb : server { listen 443 ssl; root /config/www; index index.html index.htm index.php; ### Server […]