总nginx菜鸟在这里。我搜寻了互联网,发现的所有说明和示例都是针对比我更复杂的用例的。

我正在尝试做的是:

代理http://BAREIP/guacamole/像在地址栏中的http://BAREIP:8080/guacamole/一样进行响应,但是请求完全通过端口80发送到服务器。

背景:试图为短期课程设置一些培训服务器,但最终将被拆除。没有域,不需要SSL或其他任何东西。需要能够为处于公司锁定网络上的学生提供针对班级的RDP接口,以便他们(肯定)仅对Internet开放80和443端口。我已经将鳄梨酱部分完美地设置并可以在8080上正常工作。但是我们无法确定8080是否已打开,因此我们想使用端口80。 nginx部分。我还没有做过AJP的任何事情。

我的nginx.conf文件如下所示:

user www-data;
worker_processes auto;
pid /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;

        ##
        # 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_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/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;

        server{
                location /guacamole/ {
                    proxy_pass http://localhost:8080/guacamole/;
                    proxy_buffering off;
                    proxy_http_version 1.1;
                    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                    proxy_set_header Upgrade $http_upgrade;
                    proxy_set_header Connection $http_connection;
                    proxy_cookie_path /guacamole/ /;
                    access_log off;
                }
        }
}


发生了什么:

当我转到http://BAREIP/guacamole/时,找不到404。当我进入http://BAREIP/时,得到通用的“ nginx在”页面。当我转到http://BAREIP:8080/guacamole/时,会得到鳄梨调味酱的登录页面,而当我转到http://BAREIP:8080/时,则会得到通用的“ tomcat在”页面。

我缺少使该代理工作的哪一步?

谢谢。

除了access.log:

MY_IP - - [05/Feb/2017:03:08:33 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"
MY_IP - - [05/Feb/2017:03:08:50 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"
MY_IP - - [05/Feb/2017:03:08:54 +0000] "GET /guacamole HTTP/1.1" 404 209 "-" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"
MY_IP - - [05/Feb/2017:03:08:57 +0000] "GET /guacamole/ HTTP/1.1" 404 209 "-" "Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.87 Safari/537.36"

最佳答案

您缺少listen 80;在服务器块中

10-07 22:23