Reputation: 36267
I'm working through https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-uwsgi-and-nginx-on-ubuntu-16-04 . I've reached the end of the tut and started both uwsgi and nginx as directed. I have been able to get all steps working including uwsgi as far as I am aware.
My test django site is in /home/deploy/sample as in the screenshot
If I
sudo vim /etc/nginx/sites-available/sample
I see:
server {
listen 80;
server_name sample.com www.sample.com;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/deploy/sample;
}
location / {
include uwsgi_params;
uwsgi_pass unix:/run/uwsgi/sample.sock;
}
}
Under "Install and Configure Nginx as a Reverse Proxy" the article states:
Inside, we can start our server block by indicating the port number and domain name where our first project should be accessible. We'll assume that you have a domain name for each:
I don't have a domain set up yet, but I wanted to open my VPS's ip address in my browser to see the test site.
How can I make this happen?
Upvotes: 21
Views: 39261
Reputation: 4747
For my rasperrypi running ubuntu i use this:
setup IP forwarding in router to point external static IP to IP of raspi in local network (forward at least post 80 (HTTP))
create nginx-config file under /etc/nginx/sites-available/foobar
with the following content:
server {
listen 80;
server_name <YOUR_IP_GOES_HERE>;
root /var/www/foobar; # Adjust to your site's root directory
index index.html index.htm;
}
create symlink to sites-enabled via sudo ln -s /etc/nginx/sites-available/foobar /etc/nginx/sites-enabled/
create html-file under /var/www/foobar/index.html
restart nginx to apply changes via sudo systemctl restart nginx
Upvotes: 0
Reputation: 1124
I set a default_server
with the server_name: _
in my /etc/nginx/sites-enabled/default
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
location / {
# your config goes here
}
}
This way all traffic to port 80 gets served by this server
configuration unless other rules catch it.
More info: nginx server_name wildcard or catch-all
Upvotes: 2
Reputation: 49
Better solution: Have fun testing many applications
Set host entry on dev machine (not the server). /etc/hosts C:\Windows\System32\drivers\etc\hosts
Add as one Line: ipaddress domain i.e 82.32.45.144 is your vps:
82.32.45.144 sample.com
82.32.45.144 www.sample.com
82.32.45.144 wiki.sample.com
82.32.45.144 shop.sample.com
82.32.45.144 sample.co.uk
82.32.45.144 sample.de
Upvotes: 4
Reputation: 23
You can configure nginx in an easier way rather than specifying the ip address. You can just user localhost as server_name like below. You must still use the ip address in the web browser if this stands for a web app.
server {
listen 80;
server_name localhost;
<other stuff>
}
Upvotes: -3
Reputation: 5584
You can just use your VPS's ip in place of "sample.com":
server {
listen 80;
server_name <your_ip_address>;
<other stuff>
}
If you haven't already, you may want to assign a static IP; I believe Digital Ocean gives you some free ones.
Upvotes: 43