# iap access vm

**URL:** <https://discuss.google.dev/t/iap-access-vm/150624>\
**Category:** Compute Infrastructure\
**Tags:** server-configuration, vm-manager\
**Created:** [April 4, 2024, 6:09pm UTC](https://discuss.google.dev/t/iap-access-vm/150624 "2024-04-04T18:09:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sudhir2944](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/sudhir2944/32/493_2.png) [@sudhir2944](https://discuss.google.dev/u/sudhir2944)\
**Post date:** [April 4, 2024, 6:09pm UTC](https://discuss.google.dev/t/iap-access-vm/150624/1 "2024-04-04T18:09:05Z")

</div>

how to access apache server running on port 80 on vm with only internal ip , through any means like iap.

---

<div class="post-metadata">

**Author:** ![DamianS](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/damians/32/250659_2.png) [@DamianS](https://discuss.google.dev/u/DamianS)\
**Post date:** [April 5, 2024, 5:35am UTC](https://discuss.google.dev/t/iap-access-vm/150624/2 "2024-04-05T05:35:24Z")

</div>

Hello @sudhir2944 ,

This link [1] contain all information needed to enable and use IAP. Basically, you must grant IAP access for your user, add firewall rules, enable IAP for SSH at IAM section and remove publicIP. However, if you don’t have any VM with IAP, and want to create it from scratch, this link [2] will help you.

1.[https://cloud.google.com/iap/docs/enabling-compute-howto](https://cloud.google.com/iap/docs/enabling-compute-howto)

1. [https://cloud.google.com/iap/docs/tutorial-gce](https://cloud.google.com/iap/docs/tutorial-gce)

cheers,

DamianS

---

<div class="post-metadata">

**Author:** ![nc2](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/nc2/32/212_2.png) [@nc2](https://discuss.google.dev/u/nc2)\
**Post date:** [August 9, 2024, 3:41pm UTC](https://discuss.google.dev/t/iap-access-vm/150624/3 "2024-08-09T15:41:20Z")

</div>

link 1 tells you how to enable iap, add principal, ensure iap-secured web app user role, etc. and then it tells you to find the load balancer that serves the instance group you want to restict access to. link 1 does not tell you how to do this, so if you didn’t set a load balancer up, you will need to go onto link 2.

link 2 hasn’t been updated in 2 years, and has multiple errors. such is: telling the user to go to google domains (no longer served by google) and telling the user to use debian linux 9 (eol 2022). these two guides are not applicable information to learn how to set up IAP. and especially not for internal: link 2 is external! Also: what if you did not want to enable ssh, as you wanted to block ssh connections, but just allow port 80 for example. doing the cert-bot vm and pointing domain to the load balancer will not work if it is internal. no example on how to do this from what i can see.

---

<div class="post-metadata">

**Author:** ![azzi](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/azzi/32/94291_2.png) [@azzi](https://discuss.google.dev/u/azzi)\
**Post date:** [August 10, 2024, 1:05am UTC](https://discuss.google.dev/t/iap-access-vm/150624/4 "2024-08-10T01:05:12Z")

</div>

Dear nc2,

1. Create VPC Firewall Rules with goals to open below port  
Source: 35.235.240.0/20  
Destination: Your VM with Apache Server Installed  
Port: 80

2. Ensure that your VM does not have additional OS-level firewall/software firewall. If yes, please open the port. Example: sudo ufw allow 80

3. In the local pc, install gcloud CLI [https://cloud.google.com/sdk/docs/install](https://cloud.google.com/sdk/docs/install)

4. Login to your user account with permission to access the VM with Apache Server installed. Supposedly the user account with minimum permission outlined here [https://cloud.google.com/iap/docs/using-tcp-forwarding#grant-permission](https://cloud.google.com/iap/docs/using-tcp-forwarding#grant-permission)

5. If you do not see the login screen execute gcloud auth login

6. Change the current working project into the target project using gcloud config set core/project PROJECT\_ID

7. Execute this command to start tunnelling into your VM

gcloud compute start-iap-tunnel INSTANCE\_NAME INSTANCE\_PORT   
–local-host-port=localhost:LOCAL\_PORT   
–zone=ZONE

[https://cloud.google.com/iap/docs/using-tcp-forwarding#tunneling\_other\_tcp\_connections](https://cloud.google.com/iap/docs/using-tcp-forwarding#tunneling_other_tcp_connections)

Regards,  
Izza
