Skip to content

开发环境配置域名 #53

Description

@Inchill

开发模式下每次都需要输入 IP,实在不太方便。于是通过 switchhosts 配置了如下域名:

127.0.0.1 dev.fe.com

启动服务后,可以通过域名访问项目,但是还需要跟上端口号。为了隐藏端口号,需要在 nginx 配置信息:

    server {
        listen       80;
        server_name  dev.fe.com;

        location / {
            root   html;
            index  index.html index.htm;
            proxy_pass http://127.0.0.1:8081/;
        }
    }

通过 http 访问的默认端口是 80,再代理到本地 IP 目标端口即可。重启 nginx 后访问域名,就可以显示项目了,此时的 8081 端口号就被隐藏了。

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions