首页 > 解决方案 > 如何根据动态 url 参数配置 nginx proxy_pass?

问题描述

标签: nginxparametersarguments

解决方案


好的。我找到了。我在站点可用和站点启用中使用 default.conf。这是修改 default.conf 的错误位置。正确的路径是修改 conf.d 目录中的 default.conf。

1) install nginx
2) run: 
    nginx -v  
    (nginx version: nginx/1.15.5)
3) sudo nano /etc/nginx/conf.d/default.conf

    server {
        listen 80;
            listen [::]:80;

            error_log    /var/log/nginx/your_domain_name.error.log debug;
            rewrite_log on;

            server_name your_domain_name;

            location / {
                    proxy_pass http://127.0.0.1:8888/;
        }
    }


4) sudo systemctl reload nginx
5) sudo systemctl restart nginx
6) sudo nginx -t
7) curl http://your_domain_name/

推荐阅读