Home  >  Q&A  >  body text

nginx - Please tell me how to write the configuration when https://api.***.com implicitly jumps to https://www.***.com/api/ with parameters.

Please tell me how to write the configuration when https://api.XXX.com implicitly jumps to https://www.XXX.com/api/ with parameters

曾经蜡笔没有小新曾经蜡笔没有小新2714 days ago625

reply all(4)I'll reply

  • 高洛峰

    高洛峰2017-05-16 17:09:01

    rewrite ^/(.*)$ https://www.XXX.com/api/$1 permanent;

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 17:09:01

    The reverse proxy can be configured on api..com to point to www..com/api/

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-16 17:09:01

    server {
        ...
        server_name api.xxx.com;
        location / {
            proxy_pass www.xxx.com/api/;
        }
    }

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-05-16 17:09:01

    It is recommended to use nginx proxy and open nginx.conf

    Add a new server block

    server {
        server_name api.xxx.com;
        location / {
            proxy_pass www.xxx.com/api/;
        }
    }

    reply
    0
  • Cancelreply