When requesting a resource on port 80, it is proxied to nginx on port 8080.
As a result, the resource responds to both port 80 and port 8080.

How and with what should I close the availability of the resource on port 8080, but so that it is available on port 80?

  • 2
    Reconfigure the resource itself so that it bind only to localhost - andreymal
  • In / etc / hosts chtoli register? - Medvedev Alexandr
  • No, in the settings of the resource itself - andreymal
  • Can you give a link? I do not understand how to even google it. - Medvedev Alexandr
  • one
    Due to the fact that you didn’t tell you what a resource is, it’s not possible to answer more specifically :) - andreymal

2 answers 2

Good day.

Everything is quite simple. Ubuntu 16.04

In the nginx config

 server { listen 80; server_name "доменное_имя"; location / { proxy_pass http://localhost:8080; proxy_set_header Host $host:$server_port; 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; proxy_read_timeout 90; } } 

In / etc / default / jenkins

 HTTP_HOST=127.0.0.1 JENKINS_ARGS="--webroot=/var/cache/$NAME/war --httpPort=$HTTP_PORT --httpListenAddress=$HTTP_HOST" 

    the backend should listen only to localhost, then there will be no need to make additional rules for iptables. if apache is used, then open /etc/apache/ports.conf and prescribe:

     NameVirtualHost *:8080 Listen 127.0.0.1:8080 

    after that, do not forget to restart apache, and in the nginx configs, in proxy_pass, do not forget to change the link to the backend.

    • I don't have apache there, only nginx and jenkins - Medvedev Alexandr
    • it means you need to edit the jenkins config, by default it listens to all interfaces: Binds Jenkins to the IP address represented by $HTTP_HOST. The default is 0.0.0.0 — ie listening on all available interfaces. For example, to only listen for requests from localhost, you could use: --httpListenAddress=127.0.0.1 Binds Jenkins to the IP address represented by $HTTP_HOST. The default is 0.0.0.0 — ie listening on all available interfaces. For example, to only listen for requests from localhost, you could use: --httpListenAddress=127.0.0.1 Binds Jenkins to the IP address represented by $HTTP_HOST. The default is 0.0.0.0 — ie listening on all available interfaces. For example, to only listen for requests from localhost, you could use: --httpListenAddress=127.0.0.1 - Andrey Mihalev am