Reputation: 46846
I am trying to serve a webpy application under Nginx on debian linux (RasPi).
I can successfully serve the webpy app if I use any port other than 80. But If I try to use port 80, it is not possible to hit my webpy app, I will always see instead the default "Welcome to Nginx" page.
I have tried everything I can think of the disable the default page and override it with my webpy app but nothing seems to work. I have deleted the default link, and file out of their respective directories. I have tried pointing directly to sites-enabled/webpy rather than sites-enabled/* in nginx.conf. Still result is always the same, if I hit http://[ip-address]/
I will see the welcome to nginx page.
I have tried several times nginx -s reload
and stopping/starting everything. And rebooting the device.
How do I override this so that it is serving my webpy app on port 80?
nginx.conf
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;
# multi_accept on;
}
http {
##
# Basic Settings
##
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
# server_tokens off;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
gzip_disable "msie6";
# gzip_vary on;
# gzip_proxied any;
# gzip_comp_level 6;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
# gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
##
# nginx-naxsi config
##
# Uncomment it if you installed nginx-naxsi
##
#include /etc/nginx/naxsi_core.rules;
##
# nginx-passenger config
##
# Uncomment it if you installed nginx-passenger
##
#passenger_root /usr;
#passenger_ruby /usr/bin/ruby;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*; # I even tried pointing directly to webpy instead of *
}
#mail {
# # See sample authentication script at:
# # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
#
# # auth_http localhost/auth.php;
# # pop3_capabilities "TOP" "USER";
# # imap_capabilities "IMAP4rev1" "UIDPLUS";
#
# server {
# listen localhost:110;
# protocol pop3;
# proxy on;
# }
#
# server {
# listen localhost:143;
# protocol imap;
# proxy on;
# }
#}
As far as I can tell this should make any thing inside of sites-enabled/
get served
I have only 1 thing inside of sites-enabled/
$ ls -la
total 8
drwxr-xr-x 2 root root 4096 May 31 17:49 .
drwxr-xr-x 6 root root 4096 May 31 18:08 ..
lrwxrwxrwx 1 root root 32 May 31 17:49 webpy -> /etc/nginx/sites-available/webpy
which is a link to sites-available/webpy
# webpy server
server{
listen 80; # if I set this to 8080 then I can hit the app on that port.
location / {
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param SCRIPT_FILENAME $fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_pass 127.0.0.1:9002;
}
location /static/ {
root /path/to/www;
if (-f $request_filename) {
rewrite ^/static/(.*)$ /static/$1 break;
}
}
}
I don't have any other files, or links inside of sites-enabled/
or sites-avaialbe/
I removed the default ones from these folders.
Upvotes: 2
Views: 4470
Reputation: 59571
When you set
listen 8080;
run
sudo netstat -tlnp | grep nginx
and see what ports nginx is listening on. It should not be listening on port 80 at this point. If it is try
sudo grep -rnIw "80" /etc/nginx
If nginx is listening on port 80, there must be a declaration for it somewhere under /etc/nginx
As a sanity check, I would also stop the nginx
server completely
sudo service nginx stop
and see if some other server is serving the default nginx page.
Upvotes: 5