【问题标题】:NGINX: Reverse proxy from location to portNGINX:从位置到端口的反向代理
【发布时间】:2021-03-28 00:42:18
【问题描述】:

/etc/nginx/sites-available/x.x.x.x.conf,我有这个条目:

   location /myapp {
       alias /var/www/html/myapp/public;
       index index.php;
       try_files $uri $uri/ @myapp;
 
       location ~* \.php$ {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass unix:/var/run/php/php7.1-fpm.sock;
                fastcgi_index index.php;
                include fastcgi_params;
                fastcgi_param SCRIPT_FILENAME $request_filename$fastcgi_script_name;
                fastcgi_read_timeout 7200;
       }
 
   }
 
   location @myapp {
             rewrite /myapp/(.*)$ /myapp/index.php?/$1 last;
   }

目前我访问我的网站到 x.x.x.x/myapp

如何将其代理到 x.x.x.x:8059?

【问题讨论】:

    标签: laravel nginx


    【解决方案1】:

    我不确定我是否理解您的问题。为什么不发布他们的服务器块?我还是试试吧:

        location /myapp/
        {
            proxy_pass http://x.x.x.x:8059/;
        }
    

    或者反过来:

    server
    {
        listen 8059;
        server_name x.x.x.x example.org www.example.org;
    
        # …
    
        location /
        {
            proxy_pass http://x.x.x.x:80/myapp/;
        }
    }
    

    现在你的路径很容易被破坏。在代码中更改它们或查看proxy_redirectsub(s)_filter 以进行即时更改。

    浏览器 -> 键 [F12] -> 控制台和/或网络总是有用的。

    在 Windows 上也不错:安装 Git,打开 Git Bash 并执行 curl -IL <URL>

    【讨论】:

    • 在一天结束时,我在.conf 上创建了新的服务器条目,它完美地工作。谢谢
    猜你喜欢
    • 2020-08-12
    • 1970-01-01
    • 2019-03-14
    • 2015-10-16
    • 1970-01-01
    • 2020-12-18
    • 2021-08-30
    • 1970-01-01
    • 2021-03-02
    相关资源
    最近更新 更多