Hide port 8383 in glassfish 3.1.2 - linux

I am running Glassfish 3.1.2 on Linux 6 server to deploy Oracle Apex.
I want to to hide port 8383 from url (current url say : https://sd1.domain.com:8383/apex)
80 and 443 port are already assigned for another service.
So, how can I hide port 8383 from URL.

A TCP connection is between two ip:port pairs. In case the server's port is a common one like 80/443, most browsers don't display it.
You can use a reverse proxy on port 80, that classifies incoming HTTP traffic.
It could check the subdomain in the HTTP header and then forward traffic to one of the two web servers (which both listen on dedicated ports).
With nginx the config file could look like this:
server {
server_name sd1.domain.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8383;
}
}
server {
server_name www.domain.com;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://localhost:8080;
}
}

Related

Nginx reverse proxy doesn't allow POST requests

I have a server on which I serve my 2 Node js apps, one on https://example.com/app1 and another one on https://example.com/app2. I managed to get this working by using nginx reverse proxy, setting each app to run on one port, and redirecting clients to each port based on the above addresses.
However, I'm facing this problem now where I can't save any POST requests to my MongoDB. Specifically, if I make POST request from https://example.com/app1 I get 405; if I send POST request from https://example.com:3000 everything is fine and data is saved in DB. Just to make it clear, port 3000 is the port on which app1 is running.
Can someone help me and point out to me what am I missing here? I feel like the issue here is that the app is working on port 3000 and is shown on port 80, but the data from port 80 doesn't get back to port 3000?
My reverse proxy code:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name mysubdomain.domain.com www.mysubdomain.domain.com;
location /app1 {
rewrite ^/app1/(.*)$ /$1 break;
proxy_http_version 1.1;
proxy_cache_bypass $http_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
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_pass http://myIPaddress:3000;
}
}

How to keep host when proxy to other servers in nginx

For example. User request http://user.dist.com, the request will firstly arrived at nginx server,
upstream a.hello.com {
server 10.243.26.104:8800;
}
server
{
listen 80;
server_name user.dist.com;
location /
{
proxy_pass http://a.hello.com;
}
}
and the server a.hello.com is running at Node.js, the Node sever want to get the real origin request host which should be user.dist.com, but now, the Node server get a.hello.com, so how to get the origin host?
you can use proxy_set_header-
proxy_set_header HOST $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

Nginx + NodeJs - Limit port access to a server name

i’m new to the javascript world and im trying to publish online a small react app that i‘ve done for tests.
So, first i installed nodejs in my server that already has nginx. Then expressjs, configure it and made a nginx .conf file that uses proxy_reverse to access port 8080 (chosen for nodejs). When i access the server name of that .conf file, without the port, the page it’s shown correctly.
The problem is, if i access another server name configured in my server and add the 8080 port at the end, nginx shows me my nodejs app, even with a server name different from the one configured in proxy_reverse.
Is there any way to limit access to that specific port to one specific server name and return a error everywhere else?
My nginx conf file:
server {
listen 80;
server_name react.mydomain.com;
access_log /var/log/nginx/react.access.log;
error_log /var/log/nginx/react.error.log error;
location / {
proxy_pass https://localhost:8080;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
# Enables WS support
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_redirect off;
}
}
Thanks

AWS ELB -> nginx -> socket.io node.js sticky load balancing

I am having an issue with this configuration. My AWS ELB accepts TCP connections on port 80 and forwards them using proxy protocol to an nginx instance listening on port 8080. This nginx node is supposed to use ip_hash module to stick the user to a specific node.
This is working perfectly fine, but only 2 out of the 4 nodes are being used instead of being load balanced among all of them, here is my nginx config
upstream socket_nodes {
ip_hash;
server a.server.com:2000;
server a.server.com:2001;
server a.server.com:2002;
server a.server.com:2003;
}
# Accept connections via the load balancer
server {
listen 8080 proxy_protocol;
set_real_ip_from 0.0.0.0/32;
real_ip_header proxy_protocol;
charset utf-8;
location / {
proxy_pass http://socket_nodes;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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;
}
}
Unlike "round robin" loading balancing, ip_hash means that for any given IP address, NGINX will always forward to the same application instance.

Node : Set different domain name on different port

I have created my website in node. where I am using different port for different modules.
like
http://localhost:5555/ this is for admin,
http://localhost:5050/ this is for client access.'
I am using Digitalocean Ubuntu server and I have bought domains from Godaddy.
I want to set different domain on different port.
like
http://localhost:5555/ should be "http://admin.example.com".
http://localhost:5050/ should be "http://example.com".
I have tried with nginx in Ubuntu but doesn't get any useful.
Please help me . Thanks in advance.
You need two server configs in your nginx config file, one for the admin subdomain and one for example.com itself. It should look something like this:
server {
listen 80 default;
server_name example.com .example.com ;
location / {
proxy_pass http://localhost:5050;
proxy_pass_header Server;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $remote_addr;
}
and
server {
listen 80;
server_name admin.example.com;
location / {
proxy_pass http://localhost:5555;
proxy_pass_header Server;
proxy_redirect off;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $remote_addr;
}
}

Resources