title: Cannot Access Glassfish4 Admin console via nginx location and proxy pass
body: <p>Folks,</p>
  
  <p>We have a java application running under Glassfish4.  I wanted to disable direct access to the Glassfish admin server by closing 4848 at the firewall level and accessing it via a location directive in nginx (also offloading the SSL to nginx).</p>
  
  <p>with <code>asadmin enable-secure-admin</code> turned on I can get into the admin server via <a href="https://foo.domain.com:4848" rel="nofollow">https://foo.domain.com:4848</a> and administer it normally.</p>
  
  <p>However when I disable secure admin via <code>asadmin disable-secure-admin</code> and access with the following location block</p>
  
  <pre><code>    # Reverse proxy to access Glassfish Admin server
      location /Glassfish {
      proxy_set_header               Host $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;
        proxy_max_temp_file_size      0;
        client_max_body_size           10m;
        client_body_buffer_size        128k;
        proxy_send_timeout             90;
        proxy_read_timeout             90;
        proxy_buffering                off;
        proxy_buffer_size              4k;
        proxy_buffers                  4 32k;
        proxy_busy_buffers_size        64k;
        proxy_temp_file_write_size     64k;
        proxy_pass                            http://127.0.0.1:4848;
      }
  </code></pre>
  
  <p>ala <a href="https://foo.domain.com/Glassfish" rel="nofollow">https://foo.domain.com/Glassfish</a>  I get a blank screen, and the only reference I can find in the nginx error logs is</p>
  
  <pre><code>2015/10/05 09:13:57 [error] 29429#0: *157 open() "/usr/share/nginx/html/resource/community-theme/images/login-product_name_open.png" failed (2: No such file or directory), client: 104.17.0.4, server: foo.domain.com, request: "GET /resource/community-theme/images/login-product_name_open.png HTTP/1.1", host: "foo.domain.com", referrer: "https://foo.domain.com/Glassfish"
  </code></pre>
  
  <p>Reading docs and on the net I do see that:</p>
  
  <blockquote>
    <p>Secure Admin must be enabled to access the DAS remotely</p>
  </blockquote>
  
  <p>Is what I'm trying to do simply impossible?</p>
  
  <p><strong>Edit:</strong>  As requested below is the full nginx configuration.</p>
  
  <pre><code>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            off;
      tcp_nopush          on;
      tcp_nodelay         off;
      #keepalive_timeout   65;
      types_hash_max_size 2048;
  
      # Default HTTP server on 80 port
      server {
          listen       192.168.1.10:80 default_server;
          #listen       [::]:80 default_server;
          server_name  foo-dev.domain.com;
          return 301 https://$host$request_uri;
      }
  
      # Default HTTPS server on 443 port
      server {
        listen 443;
        server_name foo-dev.domain.com;
        ssl_certificate           /etc/ssl/certs/foo-dev.domain.com.crt;
        ssl_certificate_key       /etc/ssl/certs/foo-dev.domain.com.key;
  
        ssl on;
        ssl_session_cache  builtin:1000  shared:SSL:10m;
        ssl_protocols  TLSv1 TLSv1.1 TLSv1.2;
        ssl_ciphers HIGH:!aNULL:!eNULL:!EXPORT:!CAMELLIA:!DES:!MD5:!PSK:!RC4;
        ssl_prefer_server_ciphers on;
  
        access_log            /var/log/nginx/foo-dev.domain.com.access.ssl.log;
          # Reverse proxy access to foo hospitality service implementation at BC back-end
          location /AppEndPoint {
            proxy_set_header               Host $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;
            proxy_max_temp_file_size      0;
            client_max_body_size           10m;
            client_body_buffer_size        128k;
            proxy_send_timeout             90;
            proxy_read_timeout             90;
            proxy_buffering                off;
            proxy_buffer_size              4k;
            proxy_buffers                  4 32k;
            proxy_busy_buffers_size        64k;
            proxy_temp_file_write_size     64k;
            proxy_pass                            http://foo-dev.domain.com:8080;
          }
  
          # Reverse proxy to access Glassfish Admin server
           location /Glassfish {
          proxy_set_header               Host $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;
        proxy_max_temp_file_size      0;
        client_max_body_size           10m;
        client_body_buffer_size        128k;
        proxy_send_timeout             90;
        proxy_read_timeout             90;
        proxy_buffering                off;
        proxy_buffer_size              4k;
        proxy_buffers                  4 32k;
        proxy_busy_buffers_size        64k;
        proxy_temp_file_write_size     64k;
        proxy_pass                            http://127.0.0.1:4848;
      }
  
          # Reverse proxy access to all processed servers by both client and server component
          location /messages {
            alias /integration/archive/app-messages/;
            autoindex on;
            #auth_basic "Integration Team Login";
            #auth_basic_user_file /integration/archive/app-messages/requests/.htpasswd;
  
          }
     }
  }
  </code></pre>
  
  <p>The /AppEndPoint location block is the Glassfish application server which works properly, it's only the /Glassfish location block that's giving me trouble.</p>