#nginx #nginx-config
#nginx #nginx-config
Вопрос:
Это новый сервер, работающий на Ubuntu 20.04, и мне так и не удалось отобразить веб-страницу. Я настоящий новичок, поэтому вопрос может быть глупым. Я просмотрел другие существующие темы, но не смог разобраться со своей проблемой. Дайте мне знать, если понадобится что-то еще.
$ sudo service статус nginx
● nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Sat 2021-12-11 22:02:51 CET; 11min ago
Docs: man:nginx(8)
Process: 3534 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 3535 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 3551 (nginx)
Tasks: 28 (limit: 19660)
Memory: 411.6M
CGroup: /system.slice/nginx.service
├─3536 Passenger watchdog
├─3539 Passenger core
├─3551 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
├─3559 nginx: worker process
├─3560 nginx: worker process
├─3561 nginx: worker process
└─3683 Passenger RubyApp: /home/decidim/decidim-app (production)
$ curl -i http://127.0.0.1/nginx_status
HTTP/1.1 301 Moved Permanently
Content-Type: text/html
Content-Length: 0
Connection: keep-alive
Status: 301 Moved Permanently
Location: https://127.0.0.1/nginx_status
Date: Sat, 11 Dec 2021 21:14:20 GMT
X-Powered-By: Phusion Passenger(R) 6.0.12
Server: nginx/1.18.0 Phusion Passenger(R) 6.0.12
$ sudo tail -f /var/log/nginx/access.log /var/log/nginx/error.log
==> /var/log/nginx/access.log <==
127.0.0.1 - - [11/Dec/2021:21:33:06 0100] "GET /nginx_status HTTP/1.1" 404 162 "-" "curl/7.68.0"
127.0.0.1 - - [11/Dec/2021:21:41:38 0100] "GET /nginx_status HTTP/1.1" 404 162 "-" "curl/7.68.0"
127.0.0.1 - - [11/Dec/2021:21:44:28 0100] "GET /nginx_status HTTP/1.1" 404 162 "-" "curl/7.68.0"
127.0.0.1 - - [11/Dec/2021:21:47:46 0100] "GET /nginx_status HTTP/1.1" 301 0 "-" "curl/7.68.0"
127.0.0.1 - - [11/Dec/2021:21:47:46 0100] "GET /nginx_status HTTP/1.1" 301 0 "-" "curl/7.68.0"
127.0.0.1 - - [11/Dec/2021:21:48:09 0100] "GET /nginx_status HTTP/1.1" 301 0 "-" "curl/7.68.0"
127.0.0.1 - - [11/Dec/2021:21:49:12 0100] "GET /nginx_status HTTP/1.1" 301 0 "-" "curl/7.68.0"
127.0.0.1 - - [11/Dec/2021:21:54:17 0100] "GET /nginx_status HTTP/1.1" 301 0 "-" "curl/7.68.0"
127.0.0.1 - - [11/Dec/2021:22:05:13 0100] "GET / HTTP/1.0" 301 0 "-" "Lynx/2.9.0dev.5 libwww-FM/2.14 SSL-MM/1.4.1 GNUTLS/3.6.13"
127.0.0.1 - - [11/Dec/2021:22:14:20 0100] "GET /nginx_status HTTP/1.1" 301 0 "-" "curl/7.68.0"
==> /var/log/nginx/error.log <==
[ N 2021-12-11 22:02:50.9510 3497/Tf Ser/Server.h:901 ]: [ApiServer] Freed 0 spare client objects
[ N 2021-12-11 22:02:50.9510 3497/Tf Ser/Server.h:558 ]: [ApiServer] Shutdown finished
[ N 2021-12-11 22:02:50.9510 3497/T7 Ser/Server.h:901 ]: [ServerThr.1] Freed 0 spare client objects
[ N 2021-12-11 22:02:50.9510 3497/T7 Ser/Server.h:558 ]: [ServerThr.1] Shutdown finished
[ N 2021-12-11 22:02:51.0300 3536/T1 age/Wat/WatchdogMain.cpp:1373 ]: Starting Passenger watchdog...
[ N 2021-12-11 22:02:51.0563 3539/T1 age/Cor/CoreMain.cpp:1340 ]: Starting Passenger core...
[ N 2021-12-11 22:02:51.0564 3539/T1 age/Cor/CoreMain.cpp:256 ]: Passenger core running in multi-application mode.
[ N 2021-12-11 22:02:51.0665 3539/T1 age/Cor/CoreMain.cpp:1015 ]: Passenger core online, PID 3539
[ N 2021-12-11 22:02:53.2192 3539/T5 age/Cor/SecurityUpdateChecker.h:519 ]: Security update check: no update found (next check in 24 hours)
App 3569 output: DeprecatedDSL will be removed from GraphQL-Ruby 2.0, use `.to_non_null_type` instead of `!` and remove `.activate` from /home/decidim/.rben
v/versions/2.7.1/lib/ruby/gems/2.7.0/gems/decidim-core-0.25.2/lib/decidim/core/engine.rb:89:in `block in <class:Engine>'
nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
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;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# 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/javascript text/xml application/xml application/xml rss text/javascript;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
#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;
#}
#}
$ls /etc/nginx/sites-включен/
decidim.conf
$больше /etc/nginx/sites-enabled/decidim.conf
server {
listen 80;
listen [::]:80 ipv6only=on;
server_name the_real_ip_adress_I_want_to_hide;
client_max_body_size 32M;
passenger_enabled on;
passenger_ruby /home/decidim/.rbenv/shims/ruby;
rails_env production;
root /home/decidim/decidim-app/public;
}
Ответ №1:
Как вы можете видеть в отчете curl, перенаправление на протокол https инициируется пользователем Phusion. Тогда nginx не может обработать запрос, потому что нет серверов, которые прослушивают порт 443.
Комментарии:
1. Спасибо за ваш ответ, Алексей. Как я могу это изменить?
2. Вы должны добавить директиву listen 443 в свой серверный блок в /etc/nginx/sites-enabled/decidim.conf и настроить https. См. Руководство nginx.org/en/docs/http/configuring_https_servers.html
3. Спасибо за отзывы. Мне удалось обойти проблему.