我将JIRA和Nginx与Nginx安装在同一台服务器上,作为反向代理。 从我从各种来源得知,在server.xml文件中,我必须添加一个地址=“127.0.0.1”属性,以便Tomcat不听外部IP。 但是,一旦我添加到我的8080和8443连接器,事情停止工作,即JIRA网站变得无法访问。 浏览器显示连接被拒绝/连接超时错误。
这里是Tomcat的server.xml文件configuration。
<Connector port="8080" address="127.0.0.1" maxThreads="150" minSpareThreads="25" connectionTimeout="20000" enableLookups="false" maxHttpHeaderSize="8192" protocol="HTTP/1.1" useBodyEncodingForURI="true" acceptCount="100" redirectPort="8443" disableUploadTimeout="true" proxyName=<FQDN> proxyPort="80"/> <Connector port="8443" address="127.0.0.1" SSLEnabled="true" acceptCount="100" clientAuth="false" connectionTimeout="20000" disableUploadTimeout="true" enableLookups="false" keyAlias=<value> keystoreFile=<jks file> keystorePass=<password> keystoreType="JKS" maxHttpHeaderSize="8192" maxSpareThreads="75" maxThreads="150" minSpareThreads="25" protocol="org.apache.coyote.http11.Http11Protocol" scheme="https" secure="true" sslProtocol="TLS" useBodyEncodingForURI="true"/>
以及启用网站的Nginx服务器configuration链接到站点可用文件夹 –
server { listen 80 default_server; listen [::]:80 default_server ipv6only=on; server_name <FQDN>; location / { proxy_pass http://127.0.0.1; #I have tried FQDN, real IP, :8080 suffix etc. but the response didn't change proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $host; } }
我的方法有什么问题? 它主要来自https://confluence.atlassian.com/jirakb/integrating-jira-with-nginx-426115340.html,除了添加地址属性。 HTTPS连接器块是从Atlassian的标准SSL启用指令派生出来的(我想这是自动生成的,当我configuration的时候)。
4月21日更新 :这是我的nginx.conf
user nginx; worker_processes 1; error_log /var/log/nginx/error.log warn; pid /var/run/nginx.pid; events { worker_connections 1024; } http { include /etc/nginx/mime.types; default_type application/octet-stream; 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; sendfile on; #tcp_nopush on; keepalive_timeout 65; #gzip on; include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; }
4月22日更新我试着运行curl -v FQDN,并在错误日志中得到这个消息。 terminal显示我502坏门户 –
connect() failed (111: Connection refused) while connecting to upstream, client: <IP Address>, server: <FQDN>, request: "GET / HTTP/1.1", upstream: "http://<IP>:8080/", host: <FQDN>
确保你的Nginx代理服务器的地址是“127.0.0.1”而不是你的服务器/站点的主机名或IP地址。
如果这样做了,那么当Nginx尝试在IPv6堆栈上访问它时,Tomcat连接器在IPV4上(127.0.0.1强制)可能会出现问题。
如果nginx运行,但不能连接到它的上游服务器,例如,到tomcat,那么你会得到一个50X风格的错误,而不是连接拒绝之一。
浏览器报告网站拒绝连接。 ERR_CONNECTION_REFUSED – Chethan S. Apr 21 at 15:34
这意味着你不能首先连接到nginx。 你确定它正在运行?
排查故障的最佳方法是查看系统上运行的是什么,以及端口和IP地址。 例如:
# lsof | fgrep -e LISTEN | fgrep -e tomcat -e nginx nginx 25509 root 15u IPv4 55825524 0t0 TCP *:http (LISTEN) nginx 25529 www-data 15u IPv4 55825524 0t0 TCP *:http (LISTEN) nginx 25530 www-data 15u IPv4 55825524 0t0 TCP *:http (LISTEN) nginx 25531 www-data 15u IPv4 55825524 0t0 TCP *:http (LISTEN) nginx 25532 www-data 15u IPv4 55825524 0t0 TCP *:http (LISTEN)
确保你在那里看到tomcat和nginx。
另一种方法是configuration一个防火墙(如iptables)来拒绝从外部连接到端口8080和8443的任何尝试,或者首先允许外部连接到端口22和80/443。