Reputation: 41
I was trying to forward my nginx server to tomcat (on the same server).
I followed the following tutorials:
https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-centos-7 https://www.digitalocean.com/community/tutorials/how-to-encrypt-tomcat-8-connections-with-apache-or-nginx-on-centos-7
But it still doesn't seem to work, although it did on my previous server.
Here is my nginx configuration
....
Load modular configuration files from the /etc/nginx/conf.d directory.
# See http://nginx.org/en/docs/ngx_core_module.html#include
# for more information.
include /etc/nginx/conf.d/*.conf;
upstream tomcat {
server 127.0.0.1:8080 fail_timeout=0;
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name mywebsite.be demo.mywebsite.be;
root /usr/share/nginx/html;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
#try_files $uri $uri/ =404;
proxy_pass http://tomcat/;
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-Proto $scheme;
}
....
When I restart nginx and go to my website, I get the following error:
"The page you are looking for is temporarily unavailable. Please try again later."
While my tomcat server is online and working.
I have no idea what is going wrong, I already reinstalled nginx and tomcat a couple of times.
The nginx error logs gives the following errors
2017/12/09 13:33:53 [crit] 1288#0: *73 connect() to 127.0.0.1:8080 failed (13: Permission denied) while connecting to
upstream, client: 87.**.***.244, server: mywebsite.be, request: "GET / HTTP/1.1", upstream: "http://127.0.0
.1:8080/", host: "demo.mywebsite.be"
2017/12/09 13:33:53 [crit] 1288#0: *73 connect() to 127.0.0.1:8080 failed (13: Permission denied) while connecting to
upstream, client: 87.**.***.244, server: mywebsite.be, request: "GET /nginx-logo.png HTTP/1.1", upstream: "
http://127.0.0.1:8080/nginx-logo.png", host: "demo.mywebsite.be", referrer: "https://demo.mywebsite.be/"
2017/12/09 13:33:53 [crit] 1288#0: *74 connect() to 127.0.0.1:8080 failed (13: Permission denied) while connecting to
upstream, client: 87.**.***.244, server: mywebsite.be, request: "GET /poweredby.png HTTP/1.1", upstream: "h
ttp://127.0.0.1:8080/poweredby.png", host: "demo.mywebsite.be", referrer: "https://demo.mywebsite.be/"
2017/12/09 13:33:53 [crit] 1288#0: *74 connect() to 127.0.0.1:8080 failed (13: Permission denied) while connecting to upstream, client: 87.**.***.244, server: mywebsite.be, request: "GET /favicon.ico HTTP/1.1", upstream: "http://127.0.0.1:8080/favicon.ico", host: "demo.mywebsite.be", referrer: "https://demo.mywebsite.be/"
Upvotes: 1
Views: 1718
Reputation: 41
Thanks to Richard Smith for the idea of the error log
I have solved this by running the following command:
/usr/sbin/setsebool httpd_can_network_connect true
Like explained on:
nginx proxy server localhost permission denied
Upvotes: 2