我现在要通过nginx在Google Compute Engine上部署我的node.js应用程序,但在完成所有configuration之后,我用“502 Bad Gateway”(502错误网关)错误触发了墙。 然后,在挖掘了这么多小时之后,我终于发现/etc/nginx/sites-available/server.conf中的proxy_pass字段应该是您在GCE控制台中显示的实际内部IP地址,而不是http://127.0.0.1 。 conf文件如下(有些值只是为了说明的目的): server { listen 80; listen 443 ssl; server_name example.com; ssl_certificate /etc/nginx/ssl/example.crt; ssl_certificate_key /etc/nginx/ssl/example.key; location / { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_set_header X-Forwarded-Proto $scheme; proxy_pass http://10.102.24.152:8888; } } 但是,我所遵循的所有教程都将proxy_pass的值设置为http://127.0.0.1 。 但在我的情况下,根本没有工作。 教程的例子如下: https://github.com/ShoppinPal/gcp-scripts/wiki/Setup-Nginx-on-Google-Cloud http://support.ghost.org/setup-ssl-self-hosted-ghost/ https://www.digitalocean.com/community/questions/problem-with-ssl-and-ghost 所以我现在想知道是否是使服务器正常工作的正确方法。 或者这是否导致安全问题容易发生? 或者,也许127.0.0.1是正确的数字,我身边还有其他问题?
我有这个configuration来访问geoserver: location /geoserver { proxy_set_header Host $host; proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://localhost:8080/geoserver/; proxy_pass_header Set-Cookie; proxy_redirect off; } } 每当这个工作正常,当我访问geoserver网页,但nginx不处理这样的请求: http://localhost:8080/geoserver/ows?SERVICE=WMS&access_token=4r3irW5W3DboGs…7091932%2C-5009377.085697312%2C-10018754.17139462%2C-9.313225746154785e-10 这个错误出现在控制台中: GET http://localhost:8080/geoserver/ows?SERVICE=WMS&access_token=4r3irW5W3DboGs…7091932%2C-5009377.085697312%2C-10018754.17139462%2C-9.313225746154785e-10 net::ERR_CONNECTION_REFUSED 我想让nginx用IPreplacehttp://localhost:8080 更新 我删除了斜线,但一些请求不能正常工作 OPTIONS http://localhost:8080/geoserver/wms?SERVICE=WMS&REQUEST=GetCapabilities&TILED=true&VERSION=1.1.1 net::ERR_CONNECTION_REFUSED 我在浏览器中复制了URL,并用IP代替localhost:8080 ! 完整configuration: upstream django { server unix:///tmp/uwsgi.sock; # for a file socket } server { listen 80; server_name […]
我在我的网站上设置了一个子域,它使用nginx和以下服务器configuration来托pipe一个Flask应用程序。 这是DigitalOcean上的一个液滴托pipe。 server { listen 80; server_name subdomain.mysite.com; location / { proxy_pass http://0.0.0.0:8080; proxy_redirect http://0.0.0.0:8080 http://subdomain.mysite.com; } } 我试图在我的应用程序中获取访问者的IP,但IP地址似乎是相同的,无论访问者。 我不是这个领域的专家,所以如果有人能解释发生了什么事情,以及如何获得访问者的真实IP地址,那将是非常好的。
我有nodejs服务器和一些静态内容来服务。 我使用apache 2.4来达到这个目的,因为我需要在同一台机器上configuration多个主机。 我在我的apache 2.4中configuration了我的虚拟主机 <IfModule mod_ssl.c> <VirtualHost *:443> ServerAdmin [email protected] ServerName mydomain.co.in ServerAlias mydomain.co.in ProxyPass /api http://127.0.0.1:3001/api ProxyPassReverse /api http://127.0.0.1:3001/api DocumentRoot /root/VEFA-test-admin/vefa-admin/platforms/browser/www <Directory /root/VEFA-test-admin/vefa-admin/platforms/browser/www> Options -Indexes +FollowSymLinks +MultiViews AllowOverride All Require all granted </Directory> ErrorLog ${APACHE_LOG_DIR}/error.log CustomLog ${APACHE_LOG_DIR}/access.log combined SSLCertificateFile /etc/encrypt/live/mydomain.co.in/fullchain.pem SSLCertificateKeyFile /etc/encrypt/live/mydomain.co.in/privkey.pem </VirtualHost> </IfModule> 而我的nodejs服务器在同一台机器上的portt 3001上运行。 问题是用户将访问我的网站使用mydomain.co.in得到看到的页面。 但在一种情况下,我将用户redirect到支付网关,支付网关在付款后将用户redirect到我的网站。 支付网关将用户redirect到我的网站时,会发生此问题。 Apache的错误日志说: [Thu Sep 07 […]
这是我在NginX / sites-enabled目录中的文件: upstream tomcat_server { server 192.168.1.100:8080 fail_timeout=0; } server { listen 80 default_server; listen [::]:80 default_server; server_name _____.com www._____.com; location / { proxy_set_header X-Forwarded-Host $host; proxy_set_header X-Forwarded-Server $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_pass http://tomcat_server; } } 现在,stream程如下所示: 我访问我的域名_____.com,请求被映射到我的路由器在端口39080的IP。 在我的路由器中,端口80将端口39080的请求端口转发到192.168.1.136(我的nginx服务器正在运行,单独的机器)。 Nginx正在监听端口80并提取请求。 我想要做的是将请求redirect到运行在单独机器上的Tomcat服务器,所以我把proxy_pass放到了Tomcat服务器上。 实际发生的事情是请求挂起,屏幕上出现一个空白页面。 Tomcat日志显示对请求的200 OK响应,但是它应该加载其余的内容,包括页面,图像和脚本以及其他内容。 “GET / app-portal / HTTP / 1.0”200 // 而已 [ […]
location /(0-9)* { #rewrite ^/(0-9)*$ /disp\.cgi?$1 last; rewrite ^(.*)$ /disp\.cgi?$1 break; #include proxy.conf; proxy_pass http://127.0.0.1:8999; } 嗨我想重写(0-9)*并将其传递给thttpd。 但我得到的是一个404错误:如果我inputhttp://example.com/123我得到的url'/ 123'在thttpd找不到任何build议吗? 谢谢!
在整个互联网上,我看到使用ProxyPass的人的例子,其中的语法如下所示: <Location /> ProxyPass / ajp://localhost:8009/ ProxyPassReverse / ajp://localhost:8009/ </Location> 但是,这不适合我。 在我的configurationApache 2.2.17和Tomcat 5.5,如果我尝试这样做,我的服务器将无法启动,并在日志中没有提供明确的错误信息,告诉我为什么,但如果我这样做(如下所示) ,它确实有效。 为什么是这样?? : <Location /> ProxyPass ajp://localhost:8009/ ProxyPassReverse ajp://localhost:8009/ </Location>
我有一个应用程序运行在http://www.example.com:9090/mycontext上的tomcat。 server.xml的主机名指向www.example.com 。 我没有localhost了。 我正在使用mod_proxy使用Apache转发请求到tomcat。 事情工作正常,只要ProxyPath是/mycontext 。 虚拟主机中的服务器名称设置为www.abc.com , http://www.abc.com/mycontext : www.abc.com正常工作。 不过,我想忽略上下文path,只需使用http://www.abc.com/将请求转发到http://www.example.com:9090/mycontext 。 当我这样做,Apache显示我一个空白页面。 我在这里错过了什么? 除了默认主机www.example.com之外,我没有更改server.xml任何内容。 <VirtualHost *:80> ServerName www.abc.com ProxyRequests Off ProxyPreserveHost On <Proxy *> Order deny,allow Allow from all </Proxy> ProxyPass / http://www.example.com:9090/mycontext ProxyPassReverse / http://www.example.com:9090/mycontext </VirtualHost> 谢谢
我一直在努力,基本上我想要的是这样的: 在另一个虚拟域上运行的虚拟域,运行从80到8080 我到目前为止所做的是尝试与Apache不同的组合,但我得到的是所有的虚拟域指向端口80这是我的conf: <VirtualHost domain1.com:80> DocumentRoot /var/www/domain1 <Directory "/var/www/domain1"> allow from all Options +Indexes </Directory> ServerName domain1.com </VirtualHost> <VirtualHost server.domain2.com:80> DocumentRoot /var/www <Directory "/var/www"> allow from all Options +Indexes </Directory> ServerName server.domain2.com ServerAlias www.server.domain2.com ProxyPass / http://server.domain2.com:8080/ </VirtualHost> build议? 🙁
我已经search了很高的解决scheme,希望只是我。 我想要做的是将所有stream量从我们托pipe的URLredirect到由我们购买的另一个提供商托pipe的另一台服务器,以便我们可以自定义根URL。 我正在使用httpd 2.2.3(Apache)。 这是在一个VirtualHost部分configuration的,它也是SSL(我不认为这应该很重要)。 一切都很好,除了排除。 我有(简化)是: ProxyPreserveHost On <VirtualHost 1.2.3.4:443> SSLProxyEngine On ProxyPassMatch ^/$ ! ProxyPassMatch ^/(.*)$ https://proxy.example.com/$1 ProxyPassReverse / https://proxy.example.com/ SSLEngine on … </VirtualHost> 但是它总是去远程站点。 我已经尝试了一堆组合,如: ProxyPassMatch / $! ProxyPassMatch ^ /(。*)$ https://proxy.example.com/$1 ProxyPassMatch com /! ProxyPassMatch ^ /(。*)$ https://proxy.example.com/$1 我也尝试了另一种方式(在/之后与任何东西匹配,即: ProxyPassMatch ^ /(.. +)$ https://proxy.example.com/$1 ProxyPassMatch /! ProxyPassMatch ^ /(.. *)$ https://proxy.example.com/$1 […]