# MITM proxy on Ubuntu Startup?

**URL:** <https://discourse.mitmproxy.org/t/mitm-proxy-on-ubuntu-startup/943>\
**Category:** help\
**Created:** [March 29, 2018, 3:24pm UTC](https://discourse.mitmproxy.org/t/mitm-proxy-on-ubuntu-startup/943 "2018-03-29T15:24:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dan147](https://avatars.discourse-cdn.com/v4/letter/d/e95f7d/32.png) [@dan147](https://discourse.mitmproxy.org/u/dan147)\
**Post date:** [March 29, 2018, 3:24pm UTC](https://discourse.mitmproxy.org/t/mitm-proxy-on-ubuntu-startup/943/1 "2018-03-29T15:24:09Z")

</div>

Ok, I got mitmproxy working correctly. What an awesome tool it is, thank you so much. I need one more thing though, I want it to automatically start when I boot up Ubuntu server 16.04.4. What’s the best way to accomplish that? I am looking for a startup script of some sort.

I tried this already:

```
sudo nano /etc/rc.local

```

* * *

```
/usr/local/bin/mitmproxy --showhost --ssl-insecure --set upstream_cert=false &

exit 0

```

I got the following error:

_Error: mitmproxy’s console interface requires a TTY. Please run mitmproxy in an interactive shell environment._

[pic](https://i.imgur.com/bcbnAXD.png)

Clearly I’m not doing something right. I did see [this script](https://gist.github.com/jkereako/2d31b1bd4b0c8f36113fe939d5fee93d) but it seems huge and I’m not sure it is what I am looking for.

What do you recommend? thanks

---

<div class="post-metadata">

**Author:** ![Gigiarum](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mitmproxy.org/gigiarum/32/278_2.png) [@Gigiarum](https://discourse.mitmproxy.org/u/Gigiarum)\
**Post date:** [April 5, 2018, 10:05am UTC](https://discourse.mitmproxy.org/t/mitm-proxy-on-ubuntu-startup/943/2 "2018-04-05T10:05:10Z")

</div>

I don’t know any suggested way but I can explain what I did by myself in Debian.

1. Create file `/home/user/ipx.sh` and make it executable

> #!/bin/bash  
> /usr/local/bin/mitmdump --showhost --ssl-insecure --set upstream\_cert=false &\>\> /var/log/mitmdump.log

1. Create file /lib/systemd/system/mitmdump.service

> [Unit]  
> Description=mitmdump service  
> After=network.target
> 
> [Service]  
> Type=simple  
> User=root  
> ExecStart=/home/user/ipx.sh  
> Restart=always  
> RestartSec=1
> 
> [Install]  
> WantedBy=multi-user.target

1. Reload system services

> systemctl daemon-reload

1. Enable service at startup

> systemctl enable mitmdump.service

1. Start service

> systemctl start mitmdump.service

Use mitmdump instead of mitmproxy.
