How to implement proxy mode in Postgresql server - postgresql

Postgresql 9.1 server is running in Debian 6 Linux under VPS and accessed by IPV4 address from clients.
I want to move it to other VPS server with never Debian and PostgresSQL 11.
How to implement this so that clients can use same IP address ?
Is it possible to force Postgres to redirect requests to other IP ?
Debian has redir demon ( https://manpages.debian.org/testing/redir/redir.1.en.html )
Is it best way to use it to redirect requests to 5432 port to other server ?

Yiu have several options:
If you control the DNS server, map the name to the new IP address.
Install pgBouncer on the old machine - in session pooling mode, it will work as a proxy.
Start an SSH tunnel on the old machine that redirects the requests to the new machine.

Related

How to connect from one server to another server`s postgresql database by configuring firewall

I am trying to connect from Ubuntu 16.04 server to Gentoo server`s Postgresql database. But i cannot connect to it. Ubuntu server has internet with static Ip: 93.154.53.88. In my Gentoo server has Ip: 192.168.0.104. I configured my pg_hba.conf also to Ip address of Ubuntu server. But anyway it cannot connect to it. My pg_hba.conf is like below:
host all all 93.154.52.85/32 trust
host all all 93.154.53.88/32 md5
When i ping to my Gentoo Server like below it is not going. I think I should configure some firewall settings.
ping 93.154.53.88
But When i connected my Gentoo Server`s database from second Linux server it can connect which has Ip address: 93.154.52.85. But Ubuntu server cannot connect to it. I read some post in which iptables need to be configured Please Help me What to configure and how to do it. Any help is appreciated.

How can I connect to local database on a windows machine from a tomcat server on Ubuntu in a virtual machine

I am trying to set up a server in a virtual machine using the Oracle VirtualBox. I use Ubuntu 18.04 LTS in the VirtualBox. I use PostgreSQL as my database.
In my Tomcat, I have a property file where I provide the database URL and password. I want the tomcat that is set up in the VirtualBox to be able to access a local database that is set up using PGAdmin in my Windows machine in which the VirtualBox is installed.
Is it possible to do that?
When connecting to a SQL server DB running on my host machine from a VM, I use the IP address to connect.
You can run ipconfig (or your OS's equivalent) to find the IP address of the machine serving the DB, then try to connect from your host machine via that IP address instead of the machine name.
There might be some VM-specific settings you need to tweak to allow network access between the VM and host, refer to this post for more info. Usually I have to set my VirtualBox network mode to bridged adapter.

how to access odoo remotely on network?

I have install Odoo on windows server 2008 with fixed ip and this machine connect with Ethernet in network.And my ip address is 192.168.1.200.
So how to access Odoo remotely in network.
By default odoo runs on port 8069. So try 192.168.1.200:8069.
Or if you have defined any other port in your conf file, then change 8069 to that port.
Also you can check log file(if you have specified), It will show like running on 0.0.0.0:port_number.

How to ping to my local machine from AWS EC2 instance?

I have started an ubuntu instance on AWS EC2
e.g. [ec2-user#ip-XXX-XX-XX-XX ~]$
Inside this instance, I am running a socket program for sending the data to my local system.
The program is running properly, but not able to connect to my local IP.
I am trying to ping my local system also from AWS ec2 user, but it is also not working.But I am able to ping google(8.8.8.8).
e.g. [ec2-user#ip-xxx-xx-xx-xx ~]$ ping xxx.xxx.xx.xx(my local IP)
I have set all security groups(inbound), like All Trafic,All TCP and so on.
Sorry for bad English.
Thank You
Your computer (PC) cannot be pinged from an AWS hosted machine
This is probably because the VM on your computer is using NAT outbound to talk to the LAN, which goes to an Internet router, which sends the packets to AWS
The reverse route (inbound to your PC) does not exist so starting a ping echo request from a AWS machine will not work
It is possible to get around this by opening a pass through on your router but generally this is not a great idea
However if you want to make a socket connection securely there is a way
First, start a ssh session with remote port forwarding. In the Linux ssh client this is using the -R option.
For example, if your local system is running a listening service on port 80 and your remote system has the address of 54.10.10.10 then
ssh -R 8080:localhost:80 ec2-user#54.10.10.10
Will establish a circuit such that connections to the "localhost" on the remote ec2 server on port 8080 are connected to the "localhost" on port 80 of your local machine
If you are not using a ssh cli program, most ssh clients have a facility of this sort.
Note that it is necessary to keep the ssh session open to be able to use the connections

How to access a remote Postgres database using a local GUI tool

I am running openerp(odoo) application from amazon cloud server using putty and it is ubuntu Headless(NO GUI) server. PostgreSQL is the database used for this application. Right now I am only able to access it in command mode as there is no gui in Putty. In Windows, I have installed pgadmin3. Is it possible to access it from here by configuring?
You can configure your security group to open up the postgres port accessible from your IP address (I would highly recommend the access to be limited that way). After that you can just point your GUI client the external IP address of your instance using the port where the service is running on.
I suggest you to use pgadmin gui tool to access postgres database.
You can set up an SSH tunnel in putty and use that to access the remote database with your local pgadmin3. This is a very good and secure way to do things.
First, in Putty (Connection / SSH / Tunnels) add a source port of your choice, 5000 for example. Then enter localhost:5432 for Destination (providing postgres is running on port 5432 on the server). Press Add and save your session. Next time you open your ssh connection with Putty, the tunnel will be active.
After this, set up a new connection in pgadmin3, Host: localhost and Port: 5000 (and your username and pasword, of course). Now, if the putty session is active, you should be able to connect.
In postgresql.conf file, find a line called
listen_addresses = 'localhost' and change it to '*'
Next in pg_hba.conf add this line in IPV4 local connections,
host all all (Your external ip address in CIDR format) trust
Finally restart the database using this command,sudo service postgresql restart