标签: reverse-proxy

1
推荐指数
1
解决办法
1416
查看次数

如何让不同端口上的nginx平衡到不同端口?

我正在使用 nginx 监听端口 8080,并使用下面的 nginx.conf 在端口 8081、8081、8083 和 8084 上的四个龙卷风实例上进行平衡。如何强制 nginx 监听另一个端口 8090 并平衡端口 8091、8092、8093 和 8094 ?在 [808*] 上运行的 Tornado 实例与 [809*] 上运行的不同

8080 balance on [8081, 8082, 8083, 8084]
8090 balance on [8091, 8092, 8093, 8094]
Run Code Online (Sandbox Code Playgroud)

有nginx.conf

worker_processes 16;

error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;


#master_process off;
daemon off;

events {
    worker_connections 1024;
    use epoll;
}

http {
    charset utf-8;

    # Enumerate all the Tornado servers here
    upstream frontends {
        server 127.0.0.1:8081;
        server 127.0.0.1:8082;
        server 127.0.0.1:8083;
        server 127.0.0.1:8084;
    }

    include …
Run Code Online (Sandbox Code Playgroud)

proxy reverse-proxy nginx tornado

1
推荐指数
1
解决办法
4419
查看次数

Nginx 反向代理强制 https

我们有一个使用 nginx 进行反向代理的服务器设置。该服务器会将访问者重定向到访问路径对应的服务器。现在,我想设置 nginx.conf 以强制将它们重定向到 https。问题是我收到“太多重定向”错误。我尝试使用重写并添加“proxy_set_header X-Forwarded-Proto https;” 但都不起作用。我们有办法实现这一目标吗?我们已经在 cloudflare 上设置了 ssl 证书,因此我们不需要将其添加到配置中。

以下是当前 nginx 的配置设置。

   server {
    listen       80 default_server;
    listen       [::]:80 default_server;
    server_name  localhost;
    root         /usr/share/nginx/html;

   if ($http_x_forwarded_proto = "http") {
      rewrite  ^/(.*)$  https://development-link/$1 permanent;
   }

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
            proxy_set_header X-Real-IP  $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header Host $host;
            proxy_pass http://development-elb1;
            proxy_set_header X-Forwarded-Proto https;
    }

    location /en {
            proxy_set_header X-Real-IP  $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header Host $host;
            proxy_pass …
Run Code Online (Sandbox Code Playgroud)

ssl proxy reverse-proxy nginx server

1
推荐指数
1
解决办法
1万
查看次数

无法启动apache2

Oct 04 14:13:29 ip-172-31-0-218 apache2[20813]:  * The apache2 configtest failed.
Oct 04 14:13:29 ip-172-31-0-218 apache2[20813]: Output of config test was:
Oct 04 14:13:29 ip-172-31-0-218 apache2[20813]: AH00526: Syntax error on line 13 of /etc/apache2/sites-enabled/000-default.conf:
Oct 04 14:13:29 ip-172-31-0-218 apache2[20813]: Invalid command 'ProxyPass', perhaps misspelled or defined by a module not included in the server configuration
Oct 04 14:13:29 ip-172-31-0-218 apache2[20813]: Action 'configtest' failed.
Oct 04 14:13:29 ip-172-31-0-218 apache2[20813]: The Apache error log may have more information.
Oct 04 14:13:29 ip-172-31-0-218 systemd[1]: …
Run Code Online (Sandbox Code Playgroud)

apache reverse-proxy amazon-web-services

1
推荐指数
1
解决办法
4187
查看次数

如何在nginx中包含位置块?

nginx用作 2 个网络应用程序的反向代理。
这两个 Web 应用程序 (ui) 是共享位置代理,
因为后端服务是共享的。

如何组合位置块并将它们包含在服务器中?

主机配置文件

server {
  server_name app1.com
  listen 8080;
  ...

  include /opt/bitnami/nginx/conf/vhosts/proxy.conf;
}

server {
  server_name app2.com;
  listen 8080;
  ...

  include /opt/bitnami/nginx/conf/vhosts/proxy.conf;
}
Run Code Online (Sandbox Code Playgroud)

代理配置文件

location /api/videos {
  proxy_pass ...
}
...
Run Code Online (Sandbox Code Playgroud)

但我收到以下错误:

"location" directive is not allowed here in /opt/bitnami/nginx/conf/vhosts/proxy.conf:2

reverse-proxy nginx

1
推荐指数
1
解决办法
1999
查看次数

如何允许客户在服务网站上为自己的页面设置自定义域?

我想实现Intercom为其客户提供的相同功能;它们允许为文章实现自定义域。我不太确定他们如何实施他们的方法,或者他们在幕后做了什么,确切地说。

采取以下场景;客户(NorthWind 公司)在我公司的网站(northwind.example.com)上有一个子域。

将发生以下情况:

  • 如果用户键入northwind.example.com,他们将转到northwind.example.comnorthwind.example.com出现在 url 栏中。
  • 如果用户键入example.northwind.com,他们将转到northwind.example.comexample.northwind.com出现在 url 栏中。

Intercom 实现它的方式与我希望实现它的方式之间的区别在于我使用的是subdomain,而不是目录,如上面链接的 Intercom 帮助文章中所示。


考虑到我的网站在 Nginx、NodeJS 和 MongoDB 上运行,这是我目前想到的:

  • 客户在他们的域提供商上注册了一个 CName 记录,以指向他们在我网站上的页面。
  • 客户提供他们用于我网站的 CName 记录(通过表格注册)。
  • 我在 MongoDB 中为公司及其自定义域保存了一条记录。
  • 我注册或重新注册我网站的反向代理,使用redbird允许重定向通过。

我已经研究了Redirect Web Page to another Site without changed URLDoes a Cname Change the URL that the Browser Displays

我是在正确的道路上,还是有更好的方法?

.htaccess redirect cname reverse-proxy node.js

1
推荐指数
1
解决办法
757
查看次数

如何在 IIS 反向代理上启用 SSL 卸载

我刚刚通过启用应用程序请求路由 (ARR) 并按照本文编辑 web.config 文件,为 Windows Server 上的 NodeJS 应用程序启用了反向代理:

https://learn.microsoft.com/en-us/iis/extensions/url-rewrite-module/reverse-proxy-with-url-rewrite-v2-and-application-request-routing

现在,一切工作正常,我可以从服务器外部的外部客户端访问在本地主机上运行的 NodeJS 应用程序。我想强制与我刚刚创建的反向代理建立 Https 连接。我该如何实现这一目标?

windows iis reverse-proxy arr

1
推荐指数
1
解决办法
7554
查看次数

如何使用 nginx proxy_pass api 路径到端口

我想将根位置 (/) 代理传递到端口 3000,将 /api 位置代理传递到端口 5000,这是完全可能的,对吗?

我的 nginx 配置文件:

server {
listen       80;
server_name  mywebsite.com;

location /api {
    proxy_pass http://localhost:5000;
}

location / {
    proxy_pass http://localhost:3000;
}
}
Run Code Online (Sandbox Code Playgroud)

如果我在本地执行 api 请求,我可以获得预期的输出:

myuser@myserver [conf.d]# curl localhost:5000
Hello, World!myuser@myserver [conf.d]#
Run Code Online (Sandbox Code Playgroud)

但对于 api 客户端则不然,从根路径到端口 3000 的 proxy_pass 在浏览器和 api 客户端中工作正常

笔记:

  • 我没有忘记重新加载 nginxsudo systemctl reload nginx
  • 防火墙允许两个端口中的流量,我正在使用ufw
  • 服务器操作系统是centos 7

port reverse-proxy http backend nginx

1
推荐指数
1
解决办法
1万
查看次数

HttpClient永远不会在IIS上发送请求

我有一个奇怪的问题,并尝试各种各样的事情来实现这一点.

我在我的Web API项目中有一个反向代理委托处理程序,它连接到内部资源,文件等的拦截请求,从我们的外部站点到我们DMZ内部的内部站点......

using System;
using System.Configuration;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http;

namespace Resources.API
{
    public class ProxyHandler : DelegatingHandler
    {
        protected override async Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationToken cancellationToken)
        {
            var routes = new[]{
                "/api/videos",
                "/api/documents"
            };

            // check whether we need to proxy this request
            var passThrough = !routes.Any(route => request.RequestUri.LocalPath.StartsWith(route));
            if (passThrough)
                return await base.SendAsync(request, cancellationToken);

            // got a hit forward the request to the proxy Web …
Run Code Online (Sandbox Code Playgroud)

c# asp.net iis reverse-proxy asp.net-web-api

0
推荐指数
1
解决办法
1732
查看次数

Nexus的Nginx SSL终止代理不能使用不同于443的端口

我有一个Nginx作为Nexus存储库的SSL终止反向代理.

这是配置:

server {
    server_name nexus.example.com;
    listen 443 ssl;

    ssl_certificate /etc/letsencrypt/live/nexus.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/nexus.example.com/privkey.pem;

    add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

    client_max_body_size 1G;

    location / {
        if ($http_user_agent ~* docker) {
            proxy_pass http://127.0.0.1:8082;
        }

        proxy_pass http://127.0.0.1:8081;
        proxy_cookie_path / "/; secure; HttpOnly";

        proxy_set_header   Host $http_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-Host $server_name;
        proxy_set_header   X-Forwarded-Proto $scheme;

    }

    access_log  /var/log/nginx/nexus_access.log;
    error_log /var/log/nginx/nexus_error.log;
}
Run Code Online (Sandbox Code Playgroud)

这没关系,工作正常.但是,我想在另一个端口公开Nginx,比方说10000.如果我更改配置并重新启动Nginx和Nexus,每当我访问时都会nexus.example.com:10000遇到多个错误,因为浏览器正在对资源进行请求https://nexus.example.com(没有端口) .

我认为这可能是一个缓存问题,所以我尝试了隐身模式,但它也没有用.试过一个全新的虚拟机,同样的问题,所以我放弃了缓存问题.

如果我直接在nexus.example.com:8081上公开Nexus,它也能正常工作.

可能有什么问题?

我尝试了以下解决方法,但是虽然我能够访问Nexus首页,但我无法登录.

server {
    listen 443 ssl;
    ssl_certificate /etc/letsencrypt/live/nexus.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/nexus.example.com/privkey.pem;
    location / …
Run Code Online (Sandbox Code Playgroud)

reverse-proxy nginx nexus

0
推荐指数
1
解决办法
1085
查看次数