简体   繁体   中英

How to run ngrok and apache/nginx on same server?

ngrok use port 80, apache or nginx use port 80 too. I want run ngrok and web in one server and use port 80 and use sub domain to distinguish them.

eg ngrok running at tunnel.mysite.com and nginx's web running at web.mysite.com

How to do that?

Thanks!

You can't have both listening on the same port.

You could change the port for ngrok (eg to 8080) and then setup a new virtual host in nginx to reverse proxy http://tunnel.mysite.com to http://ngrok:8080 .

Example nginx config:

server {
    server_name web.mysite.com;
    ...
    }
}

server {
    server_name tunnel.mysite.com;
    location / {
        proxy_pass http://ngrok_IP:8080;     
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM