V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
miniyao
V2EX  ›  问与答

nginx 怎么配置二级域名自动跳转到对应子路径上?中间用了 uwsgi、gunicorn 的 web 服务

  •  
  •   miniyao · 2017 年 12 月 5 日 · 1290 次点击
    这是一个创建于 3041 天前的主题,其中的信息可能已经有所发展或是发生改变。

    nginx + uwsgi/gunicorn + app

    希望把 xxx.example.com 自动跳转到 example.com/xxx 路径上去,需要把 xxx 的值传到 location 的 gateway 里面去吗?

        server {
        listen 80;
        server_name example.com;
        rewrite ^/(.*)$ permanent;
    
        location / {
            proxy_pass http://127.0.0.1:8077;
            proxy_redirect     off;
            proxy_set_header   Host $host;
            proxy_set_header   X-Real-IP $remote_addr;
            proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header   X-Forwarded-Host $server_name;
        }
    
        location /static/ {
            root /usr/share/nginx/project/app/;
        }
    
        }  
    
    目前尚无回复
    关于   ·   帮助文档   ·   自助推广系统   ·   博客   ·   API   ·   FAQ   ·   Solana   ·   2578 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 23ms · UTC 15:13 · PVG 23:13 · LAX 08:13 · JFK 11:13
    ♥ Do have faith in what you're doing.