1

I have a Spring boot application running on embedded Tomcat running on Vagrant CentOS box. It running on port 8080, so I can access application in web browser. I need to set up Nginx proxy server that listen to port 80 and redirect it to my application.

I'm getting this error it the Nginx log:

[crit] 2370#0: *14 connect() to 10.0.15.21:8080 failed (13: Permission denied) while connecting to upstream, client: 10.0.15.1, server: , request: "GET / HTTP/1.1", upstream: "http://10.0.15.21:8080/", host: "10.0.15.21"

All the set up examples looks pretty much similar and the only answer I could find that might help was this one. However it doesn't change anything.

Here is my server config located in /etc/nginx/conf.d/reverseproxy.conf

server {
    listen 80;
    location / {
        proxy_pass http://10.0.15.21:8080;
        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;
    }
}

And here is my nginx.conf file'

user root;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

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;

    sendfile            on;
    sendfile            on;
    tcp_nopush          on;
    tcp_nodelay         on;
    keepalive_timeout   65;
    types_hash_max_size 2048;

    include             /etc/nginx/mime.types;
    default_type        application/octet-stream;

    include /etc/nginx/conf.d/*.conf;

}

Don't know if this is related, but under journalctl -u nginx I can see this log.

systemd1: Failed to read PID from file /run/nginx.pid: Invalid argument

Community
  • 1
  • 1
Sergii Bishyr
  • 8,331
  • 6
  • 40
  • 69

1 Answers1

1

centos has SELinux enabled by default.

You would need to turn if off by running

setsebool httpd_can_network_connect on

There are some information about this on internet if you want to learn more. to make it persistent you can run

setsebool -P httpd_can_network_connect on
Frederic Henri
  • 51,761
  • 10
  • 113
  • 139