Web application is loaded only in the form address ip:8080

224 Views Asked by At

Web application is loaded only in the form address ip:8080.

I've a web application that is configured as Wildfly server and Nginx reverse proxy, I am trying to load this application in the browser without success, because the application load only with ip address information.

This is my first time that I use Wildfly server and Nginx then I don't have experience, but I've reading high. My application is a Maven project in Java, all in the project is working fine.

Below is my configurations.

My standalone.xml:

<subsystem xmlns="urn:jboss:domain:deployment-scanner:2.0">
    161             <deployment-scanner name="itcmedbr.war" path="deployments" relative-to="jboss.server.base.dir" scan-interval="5000" auto-deploy-exploded="true" runtime-failure-causes-rollback="${jboss.deployment.scanner.rollback.on.failure:false}"/>
    162         </subsystem>

My nginx conf:

      1 server {
      2     listen       80;
      3     listen       [::]:80;
      4     server_name  itcmedbr.com www.itcmedbr.com;
      5
      6     # Load configuration files for the default server block.
      7
      8     location / {
      9         root    /opt/wildfly/standalone/data/content/39/c296b5d6d608465514ecce78b062f85b5f9001/content;
     10         proxy_set_header X-Forwarded-For        $remote_addr;
     11         proxy_set_header Host                   $server_name:$server_port;
     12         proxy_set_header Origin                 http://myipaddress;
     13         proxy_set_header Upgrade                $http_upgrade;
     14
     15         proxy_pass http://127.0.0.1:8080;
     16     }
     17
     18     error_page 404 /404.html;
     19         location = /40x.html {
     20     }
     21
     22     error_page 500 502 503 504 /50x.html;
     23          location = /50x.html {
     24     }
     25 }

In my mind I understanding that when is made a deploy a file is created so I looked in the wildfly folders and found this file that I specified in the root parameter of my nginx.conf, but the problem still the same, i.e domain.com and load the page.

What I must to do to solve this problem?

Thanks and best regards.

1 - deploy the war file

ls /opt/wildfly/standalone/deployments/
itcmedbr.war  itcmedbr.war.deployed  README.txt

2 - configuration of nginx:

# For more information on configuration, see:
#   * Official English Documentation: http://nginx.org/en/docs/
#   * Official Russian Documentation: http://nginx.org/ru/docs/

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

 # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
 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;
     tcp_nopush          on;
     tcp_nodelay         on;
     keepalive_timeout   65;
     types_hash_max_size 2048;

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

     # 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;

     server {
         listen       80 default_server;
         listen       [::]:80 default_server;
         server_name  _;
         root         /usr/share/nginx/html;

         # Load configuration files for the default server block.
         # include /etc/nginx/default.d/*.conf;

         location / {
         }
 
         error_page 404 /404.html;
             location = /40x.html {
         }

         error_page 500 502 503 504 /50x.html;
             location = /50x.html {
         }
     }

 # Settings for a `TLS` enabled server.
 #
 #    server {
 #        listen       443 ssl http2 default_server;
 #        listen       [::]:443 ssl http2 default_server;
 #        server_name  _;
 #        root         /usr/share/nginx/html;
 #
 #        ssl_certificate "/etc/pki/nginx/server.crt";
 #        ssl_certificate_key "/etc/pki/nginx/private/server.key";
 #        ssl_session_cache shared:SSL:1m;
 #        ssl_session_timeout  10m;
 #        ssl_ciphers PROFILE=SYSTEM;
 #        ssl_prefer_server_ciphers on;
 #
 #        # Load configuration files for the default server block.
 #        include /etc/nginx/default.d/*.conf;
 #
 #        location / {
 #        }
 #
 #        error_page 404 /404.html;
 #            location = /40x.html {
 #        }
 #
 #        error_page 500 502 503 504 /50x.html;
 #            location = /50x.html {
 #        }
 #    }
 }

2.1 - configuration of itcmedbr.com.conf in /etc/nginx/conf.d:

server {
     listen       80;
     listen       [::]:80;
     server_name  itcmedbr.com www.itcmedbr.com;

     listen       443 ssl http2 default_server;
     listen       [::]:443 ssl http2 default_server;

     # Redirect all port 80 (HTTP) requests to port 443 (HTTPS).
     return 301 https://itcmedbr.com$request_uri;

     # Load configuration files for the default server block.

     location / {
         proxy_set_header Origin                 http://ipaddress;

         proxy_pass http://127.0.0.1:8080;
     }

     error_page 404 /404.html;
         location = /40x.html {
     }

     error_page 500 502 503 504 /50x.html;
          location = /50x.html {
     }
 }

3 - status nginx:

Loaded: loaded (/usr/lib/systemd/system/nginx.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2024-03-03 18:36:43 -03; 41s ago

4 - status wildfly.service:

Loaded: loaded (/etc/systemd/system/wildfly.service; enabled; vendor preset: disabled)
   Active: active (running) since Sun 2024-03-03 18:25:40 -03; 41s ago

5 - firewall ports:

firewall-cmd --list-all
public (active)
  target: default
  icmp-block-inversion: no
  interfaces: eth0
  sources:
  services: http https ssh
  ports: 8080/tcp 9990/tcp 3306/tcp 80/tcp 443/tcp
  protocols:
  forward: no
  masquerade: no
  forward-ports:
  source-ports:
  icmp-blocks:
  rich rules:

ss -tunelp | grep 80
tcp   LISTEN 0      511           0.0.0.0:80         0.0.0.0:*    users:(("nginx",pid=159107,fd=6),("nginx",pid=159105,fd=6)) ino:2538418 sk:4b <->
tcp   LISTEN 0      2048   xxx.xxx.xx.xxx:8080       0.0.0.0:*    users:(("java",pid=158828,fd=494)) uid:990 ino:2536856 sk:4c <->
tcp   LISTEN 0      511              [::]:80            [::]:*    users:(("nginx",pid=159107,fd=7),("nginx",pid=159105,fd=7)) ino:2538419 sk:4f v6only:1 <->
 
 ss -tunelp | grep 443
tcp   LISTEN 0      511           0.0.0.0:443        0.0.0.0:*    users:(("nginx",pid=159107,fd=8),("nginx",pid=159105,fd=8)) ino:2538420 sk:4d <->
tcp   LISTEN 0      2048   xxx.xxx.xx.xxx:8443       0.0.0.0:*    users:(("java",pid=158828,fd=495)) uid:990 ino:2536857 sk:4e <->
tcp   LISTEN 0      511              [::]:443           [::]:*    users:(("nginx",pid=159107,fd=9),("nginx",pid=159105,fd=9)) ino:2538421 sk:50 v6only:1 <->

Now when I typing itcmedbr.com I receiving " This site can't be reached The connection was reset." and if I typing in the browser ip:8080 the "Welcome to Wildfly" page is loaded.

Trying to solve the problem I did the following steps:

1 - uninstall and remove Nginx

2 - install nginx with certbot

     yum install nginx certbot python3-certbot-nginx

3 - create my server conf

     vi /etc/nginx/conf.d/itcmedbr.conf
 server {
         server_name     itcmedbr.com;
 }

4 - configure certbot

     certbot --nginx
         define email
         define domain

5 - reload, restart, nginx and wildfly

6 - when test nginx result is:

      nginx -t
      nginx: [warn] conflicting server name "itcmedbr.com" on 0.0.0.0:80, ignored <==(I don't know why this occur and how to solve this)
      nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
      nginx: configuration file /etc/nginx/nginx.conf test is successful

7 - result of nginx.conf

 # For more information on configuration, see:
 #   * Official English Documentation: http://nginx.org/en/docs/
 #   * Official Russian Documentation: http://nginx.org/ru/docs/

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

 # Load dynamic modules. See /usr/share/doc/nginx/README.dynamic.
 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;
     tcp_nopush          on;
     tcp_nodelay         on;
     keepalive_timeout   65;
     types_hash_max_size 2048;

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

     # 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;

     server {
         listen       80 default_server;
         listen       [::]:80 default_server;
         server_name  _;
         root         /usr/share/nginx/html;

         # Load configuration files for the default server block.
         include /etc/nginx/default.d/*.conf;

         location / {
         }

         error_page 404 /404.html;
             location = /40x.html {
         }

         error_page 500 502 503 504 /50x.html;
             location = /50x.html {
         }
     }

 # Settings for a TLS enabled server.

     server {
         listen       443 ssl http2 default_server;
         listen       [::]:443 ssl http2 default_server;
         server_name  _;
         root         /usr/share/nginx/html;

         ssl_certificate "/etc/ssl/certs/nginx-selfsigned.crt";
         ssl_certificate_key "/etc/ssl/private/nginx-selfsigned.key";
         ssl_session_cache shared:SSL:1m;
         ssl_session_timeout  10m;
         ssl_ciphers PROFILE=SYSTEM;
         ssl_prefer_server_ciphers on;

         # Load configuration files for the default server block.
         include /etc/nginx/default.d/*.conf;

         location / {
         }

         error_page 404 /404.html;
             location = /40x.html {
         }

         error_page 500 502 503 504 /50x.html;
             location = /50x.html {
         }
     }



     server {
     server_name itcmedbr.com; # managed by Certbot
         root         /usr/share/nginx/html;

         # Load configuration files for the default server block.
         include /etc/nginx/default.d/*.conf;

         location / {
         }

         error_page 404 /404.html;
             location = /40x.html {
         }

         error_page 500 502 503 504 /50x.html;
             location = /50x.html {
         }


     listen [::]:443 ssl ipv6only=on; # managed by Certbot
     listen 443 ssl; # managed by Certbot
     ssl_certificate /etc/letsencrypt/live/itcmedbr.com/fullchain.pem; # managed by Certbot
     ssl_certificate_key /etc/letsencrypt/live/itcmedbr.com/privkey.pem; # managed by Certbot
     include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
     ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

 }

     server {
     if ($host = itcmedbr.com) {
         return 301 https://$host$request_uri;
     } # managed by Certbot


         listen       80 ;
         listen       [::]:80 ;
      server_name itcmedbr.com;
      return 404; # managed by Certbot

 }}

How we can see nginx.conf was updated by certbot and is managed by certbot too.

After all of this now I've a new problem that when I typing my ipaddress:9990 in the browser to open wildfly console I receive the same message "This site can't be reached."

0

There are 0 best solutions below