0

I have ip address of ubuntu server and can connect through ssh

like

ssh abcd@13.12.9.9
# and this ask me for password and then i connect to this ubuntu server

My Question how i set this ip of ubuntu server in nginx server name in proper way so that i can access this nginx server globally

server {
listen 80;
server_name 13.12.9.9; # this is correct syntax or wrong or i give it like this abcd@13.12.9.9

location / {
  include proxy_params;
  proxy_pass http://unix:/home/abcd/myFlaskApp/app.sock;
    }
}                

Any help would be appreciated Thanks.

Farid
  • 3
  • 3
  • Do you have any reason to use the word "globally" in your question? Does it imply the IP address is a private address? – Dylan Jul 08 '22 at 19:36
  • Questions seeking installation, configuration or diagnostic help must include the desired end state, the specific problem or error, sufficient information about the configuration and environment to reproduce it, and attempted solutions. Questions without a clear problem statement are not useful to other readers and are unlikely to get good answers. – djdomi Jul 09 '22 at 13:55
  • Hi @Dylan thanks and the world globally access what i mean is i have flask app and the main module that will run with help of gunicorn and nginx the ubuntu server has this app and and want to run the gunicorn and nginx server up and the nginx server name should be this ip which i can use remotly for ssh conection and now this ip i want to assign to server name so every body can send request to that ip in post method way. So that module will return response.i just want that what i has mention the assigning way is right or wrong . – Farid Jul 11 '22 at 16:57

3 Answers3

0

Assuming you have Nginx on the same server of your app, you shouldn't have to specify an IP as Nginx have syntax for that, this should do the trick:

server {

listen      80 default_server;
listen [::]:80 default_server;
server_name _;

location / {
  include proxy_params;
  proxy_pass http://unix:/home/abcd/myFlaskApp/app.sock;
    }

}   
  • Hi Alejandro Vidauree in my use case i want that any client just send request to this ip and it will get response . So this method as you have mention will work .? – Farid Jul 11 '22 at 17:02
  • Yes, it should, the simplest way to explain it is that Nginx as well as any other Web server will receive a call from outside on a specified port, by default it's port 80, so that configuration with the instructions `listen 80 default_server;` and `listen [::]:80 default_server;` will listen any call made on the port 80 to your server where a server_name is not provided, the `server_name _;` tells Nginx to process calls made to the IP instead, make sure your location is well defined to point to your app/website. – Alejandro Vidaurre Jul 13 '22 at 14:00
  • @ Alejandro Vidaurre thank you so much for helping me – Farid Jul 13 '22 at 17:27
0

You can always look at official documentation to get precise and easy to understand answer to your questions.
According to the following document of nginx:
server_names_nginx

You can use ip address in your server name

server_name 13.12.9.9;
Salar
  • 142
  • 8
0

You don't have to specify anything, nginx will automatically bind to all the available IP addresses in the machine (it binds to 0.0.0.0 by default. You can tell nginx to bind exclusively to a specified IP address in the listen configuration, like this:

server {
    listen 13.12.9.9:80;
    listen 13.12.9.9:443 ssl;
    # Your configuration

}

So the configuration in this block binds exclusively to 13.12.9.9. So it's only accessible through that IP. So for example you can't access to it querying 127.0.0.1.