我正在尝试在debian linux(RasPi)上的Nginx下提供webpy应用程序。
如果我使用80以外的任何端口,我可以成功提供webpy应用程序。但是如果我尝试使用端口80,则无法点击我的webpy应用程序,我将始终看到默认的"欢迎到Nginx"页。
我已经尝试了一切我能想到的禁用默认页面并使用我的webpy应用程序覆盖它但似乎没有任何效果。我删除了默认链接,并将文件从各自的目录中删除。我已经尝试直接指向sites-enabled / webpy而不是nginx.conf中的sites-enabled / *。结果总是一样,如果我点击http://[ip-address]/
,我会看到欢迎来到nginx页面。
我已多次尝试nginx -s reload
并停止/启动所有内容。并重启设备。
如何覆盖它以便它在端口80上提供我的webpy应用程序?
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;
# }
#}
据我所知,这应该使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
这是指向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;
}
}
}
我没有任何其他文件或sites-enabled/
或sites-avaialbe/
内的链接我从这些文件夹中删除了默认文件。
答案 0 :(得分:4)
设置
时listen 8080;
运行
sudo netstat -tlnp | grep nginx
并查看nginx正在侦听的端口。此时它不应该在端口80上侦听。如果是试试
sudo grep -rnIw "80" /etc/nginx
如果nginx正在侦听端口80,则必须在/etc/nginx
作为一个完整性检查,我也会完全停止nginx
服务器
sudo service nginx stop
并查看是否有其他服务器正在提供默认的nginx页面。