Я запускаю Ubuntu 17.10 на моем сервере, у меня установлен и запущен nginx, могут выполняться и
sudo systemctl restart nginx
, и
sudo /etc/init.d/nginx status
, и возвращается, что он работает
● 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 Fri 2019-05-31 10:54:07 +08; 47min ago
Docs: man:nginx(8)
Process: 99211 ExecStop=/sbin/start-stop-daemon --quiet --stop --retry QUIT/5 --pidfile /run/nginx.pid (code=exited, status=0/SUCCESS)
Process: 99225 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Process: 99213 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, status=0/SUCCESS)
Main PID: 99228 (nginx)
Tasks: 3 (limit: 19660)
Memory: 2.3M
CPU: 10ms
CGroup: /system.slice/nginx.service
├─99228 nginx: master process /usr/sbin/nginx -g daemon on; master…n;
├─99229 nginx: worker process
└─99230 nginx: worker process
May 31 10:54:07 UbuntuSvr systemd[1]: Starting A high performance web serve…r...
May 31 10:54:07 UbuntuSvr systemd[1]: Started A high performance web server…ver.
Hint: Some lines were ellipsized, use -l to show in full.
Однако, когда я получаю доступ к своему IP: 8080 (потому что я установил 8080 в конфигурацию nginx) или к своему IP: 80 (я просто пытаюсь) или к моему IP: 8082 (потому что я строю свой угловой интерфейс и конфигурацию apiBaseUrl вhttp://localhost:8082) показывает
This site can’t be reached
ERR_CONNECTION_RESET
в Chrome и safari can't open the page, ...because server where this page is located isn't responding
в Safari.
Я попытался проверить брандмауэр:
sudo ufw status
этопоказывает:
Status: active
To Action From
-- ------ ----
8082/tcp ALLOW Anywhere
8080/tcp ALLOW Anywhere
8082/tcp (v6) ALLOW Anywhere (v6)
8080/tcp (v6) ALLOW Anywhere (v6)
и другие проверки:
netstat -natup | grep LISTEN
показывает:
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:3002 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:27017 0.0.0.0:* LISTEN -
tcp 0 0 0.0.0.0:5355 0.0.0.0:* LISTEN -
tcp6 0 0 :::8080 :::* LISTEN -
tcp6 0 0 :::80 :::* LISTEN -
tcp6 0 0 :::86 :::* LISTEN -
tcp6 0 0 :::22 :::* LISTEN -
tcp6 0 0 :::5355 :::* LISTEN -
и sudo netstat -tanpl|grep nginx
показывает:
tcp 0 0 0.0.0.0:8080 0.0.0.0:* LISTEN 99228/nginx: master
tcp6 0 0 :::8080 :::* LISTEN 99228/nginx: master
вот мое /etc/nginx/sites-available/default
содержимое файла:
> server {
> listen 80 default_server;
> listen [::]:80 default_server;
>
> root /var/www/html;
> index index.html index.htm index.nginx-debian.html;
>
> server_name _;
>
> location / {
> try_files $uri $uri/ /index.html =404;
> } }
Я собрал свой веб-сайт с помощью ng build --prod
и скопировал все содержимое в сгенерированной папке (в папке "dist") в папку /var/www/html/
(где также есть файл "index.nginx-debian.html")
Дополнительная информация: у меня есть серверная часть, работающая на pm2, nodejs. База данных работает на mongodb. Обновление: мой файл nginx.conf как required:
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; # 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;
# }
#}
Еще одна вещь, которую я заметил: если я запускаю эту команду с моего сервера: curl -I http://localhost:8080
, тогда я получаю:
HTTP/1.1 200 OK
Server: nginx/1.14.0
Date: Fri, 31 May 2019 06:58:26 GMT
Content-Type: text/html
Content-Length: 700
Last-Modified: Fri, 31 May 2019 02:44:47 GMT
Connection: keep-alive
ETag: "5cf0951f-2bc"
Accept-Ranges: bytes
, но если я заменю localhost на myserverIP:
curl -I http://my.server.ip.address:8080
тогда я получил:
curl: (7) Failed to connect to 13.67.51.66 port 8080: Connection timed out
Мой сервер также использует облачную службу Azure, блокирует ли это ICMP, и тогда я не могу использовать IP для подключения к своему серверу извне?Как я мог тогда поступить в этом случае?
Я ожидаю одну из этих попыток от моего локального ноутбука, по крайней мере, я мог бы получить: 
но этоне.
Знаете ли вы причину этого, пожалуйста, и как я могу заставить его работать?Большое спасибо!