我正在尝试在Debian Linux(RasPi)上的Nginx下提供一个webpy应用程序。
如果我使用80以外的任何端口,则可以成功提供webpy应用程序。但是,如果尝试使用端口80,则无法运行我的webpy应用程序,我将始终看到默认的“欢迎使用Nginx”页面。
我已经尝试了所有我能想到的禁用默认页面并用我的webpy应用程序覆盖它的方法,但是似乎没有任何效果。我已经删除了默认链接,并将文件从各自的目录中删除。我试过直接在nginx.conf中指向启用了site / webpy的站点,而不是启用了site / *的站点。结果仍然是相同的,如果我点击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;
# }
#}
Run Code Online (Sandbox Code Playgroud)
据我所知这应该使任何事情都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
Run Code Online (Sandbox Code Playgroud)
这是指向网站可用/ 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;
}
}
}
Run Code Online (Sandbox Code Playgroud)
我没有任何其他文件或链接的内部sites-enabled/或sites-avaialbe/我删除这些文件夹在默认的。
设定时
listen 8080;
Run Code Online (Sandbox Code Playgroud)
跑
sudo netstat -tlnp | grep nginx
Run Code Online (Sandbox Code Playgroud)
并查看nginx正在监听哪些端口。此时,它不应在端口80上监听。如果尝试
sudo grep -rnIw "80" /etc/nginx
Run Code Online (Sandbox Code Playgroud)
如果nginx在端口80上侦听,则必须在下面的某个位置声明它 /etc/nginx
作为健全性检查,我还将nginx完全停止服务器
sudo service nginx stop
Run Code Online (Sandbox Code Playgroud)
并查看是否有其他服务器在提供默认的nginx页面。
| 归档时间: |
|
| 查看次数: |
2155 次 |
| 最近记录: |