【问题标题】:Can't access nginx server from outside [closed]无法从外部访问 nginx 服务器 [关闭]
【发布时间】:2015-08-06 15:12:01
【问题描述】:

我最近不得不在 centOS 7 服务器上设置 nginx 服务器。 为了运行dataiku软件。

一切似乎都运行良好,但一旦我尝试访问这些页面,我就一无所获。

通过本地的 elinks,我设法获得了 nginx 默认网页,但不是来自我的浏览器,所以我认为它来自我的 nginx 配置。

这是我的 nginx.conf :

user  nginx;
worker_processes  1;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
worker_connections  1024;
}



 http {
include       /etc/nginx/mime.types;
default_type  application/octet-stream;

log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                  '$status $body_bytes_sent "$http_referer" '
                  '"$http_user_agent" "$http_x_forwarded_for"';

access_log  /var/log/nginx/access.log  main;

sendfile        on;
#tcp_nopush     on;

keepalive_timeout  65;

#gzip  on;

include /etc/nginx/conf.d/*.conf;
}

这是 default.conf 包含的文件:

server {
    listen       80 default;
    server_name _;
    #charset koi8-r;
    #access_log  /var/log/nginx/log/host.access.log  main;

location / {
    root   /usr/share/nginx/html;
    index  index.html index.htm;
}

#error_page  404              /404.html;

# redirect server error pages to the static page /50x.html
#
error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   /usr/share/nginx/html;
}

# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
#    proxy_pass   http://127.0.0.1;
#}

# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
#    root           html;
#    fastcgi_pass   127.0.0.1:9000;
#    fastcgi_index  index.php;
#    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
#    include        fastcgi_params;
#}

# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
#    deny  all;
#}
}

我真的需要这个服务器正常运行并且可以访问你知道吗?

感谢您的阅读。

【问题讨论】:

  • 问题解决了吗?

标签: nginx centos data-science-studio


【解决方案1】:

你应该在公共区域添加一个新规则,因为 CentOS 7 有一个防火墙。 试试:

firewall-cmd --zone=public --add-service=http

去吧!

【讨论】:

  • 这行得通。也添加了 https。
  • 这太棒了。如果您希望在重新启动后继续存在,请参阅下面的答案。
【解决方案2】:

将规则添加到永久集中并重新加载 FirewallD:

sudo firewall-cmd --zone=public --add-service=http --permanent
sudo firewall-cmd --reload

应该可以!

【讨论】:

  • 非常感谢,
【解决方案3】:

您错过了 proxy_pass 配置,在您的情况下,该配置实际上是通过 HTTP 端口 80 将所有请求从后端转换到外部:

server {
    # Host/port on which to expose Data Science Studio to users
    listen 80;
    server_name _;
    location / {
        # Base url of the Data Science Studio installation
        proxy_pass http://DSS_HOST:DSS_PORT/;
        proxy_redirect off;
        # Allow long queries
        proxy_read_timeout 3600;
        proxy_send_timeout 600;
        # Allow large uploads
        client_max_body_size 0;
        # Allow protocol upgrade to websocket
        proxy_http_version 1.1;
        proxy_set_header Host $http_host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

官方文档对此非常清楚:http://doc.dataiku.com/dss/latest/installation/reverse_proxies.html

确保您已更新 Nginx 以便能够处理 WebSocket 请求。

【讨论】:

    猜你喜欢
    • 2012-01-18
    • 1970-01-01
    • 2023-03-22
    • 1970-01-01
    • 1970-01-01
    • 2020-09-16
    • 1970-01-01
    • 1970-01-01
    • 2021-06-22
    相关资源
    最近更新 更多