skip to Main Content

Can’t connect to application through External IP.

I started gerrit code review application on GCP’s vm instance(CentOS 7).
It works on http://localhost:8080 and I can’t connect to it through external IP. Also I tried to create NGINX reverse proxy, but probably my configuration is wrong. By the way after installing NGINX, the starter page were shown on external ip.

# nginx configuration /etc/nginx/conf.d/default.conf
server {
listen 80;
server_name localhost;

auth_basic "Welcomme to Gerrit Code Review Site!";

location / {
    proxy_pass   http://127.0.0.1:8080;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header Host $host;
}
}

gerrit.config
[httpd]
    listenUrl = proxy-http://127.0.0.1:8080/

2

Answers


  1. You use localhost as a server_name. I think that may cause conflict, because you connect to your server externally. You don’t need server_name, cause you are going connect to your server by ip. And I recommend you enable logs in your nginx config. It will help you with bug fixing.

    I recommend you try this config:

    server {
    listen 80;
    
    access_log /var/log/nginx/gerrit_access.log;
    error_log /var/log/nginx/gerrit_error.log;
    
    location / {
        proxy_pass   http://127.0.0.1:8080;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_set_header Host $host;
    }
    }
    
    Login or Signup to reply.
    1. add a line in /etc/hosts
      127.0.0.1 internal.domain

    2. Update proxy config
      proxy_pass http://internal.domain:8080;

    It works with me

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search