Skip to content

Instantly share code, notes, and snippets.

@sohgoh
Forked from f1sherman/forwarding-example.md
Last active December 22, 2015 06:59
Show Gist options
  • Save sohgoh/f7e8e7e1b332540b6316 to your computer and use it in GitHub Desktop.
Save sohgoh/f7e8e7e1b332540b6316 to your computer and use it in GitHub Desktop.

Revisions

  1. sohgoh revised this gist Dec 22, 2015. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion forwarding-example.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    Add the following to `/etc/pf.anchors/myname`:
    ```shell
    // 以前は port {80 8080} -> 127.0.0.1 port 8080 みたいな書き方が出来たけど今は無視される?ようなので注意
    // 以前は port {80 8080} -> 127.0.0.1 port 8080 みたいな書き方が出来たけどEl Capitanから無視される?ようなので注意
    rdr pass on lo0 inet proto tcp from any to any port 80 -> 127.0.0.1 port 4000
    rdr pass on lo0 inet proto tcp from any to any port 443 -> 127.0.0.1 port 4001
    ```
  2. sohgoh revised this gist Dec 21, 2015. 1 changed file with 7 additions and 2 deletions.
    9 changes: 7 additions & 2 deletions forwarding-example.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    Add the following to `/etc/pf.anchors/myname`:
    ```shell
    // 以前は port {80 8080} -> 127.0.0.1 port 8080 みたいな書き方が出来たけど今は無視されるので注意
    // 以前は port {80 8080} -> 127.0.0.1 port 8080 みたいな書き方が出来たけど今は無視される?ようなので注意
    rdr pass on lo0 inet proto tcp from any to any port 80 -> 127.0.0.1 port 4000
    rdr pass on lo0 inet proto tcp from any to any port 443 -> 127.0.0.1 port 4001
    ```
    @@ -39,4 +39,9 @@ Add the following to `/Library/LaunchDaemons/com.apple.pfctl-myname.plist`:
    Run the following command to have it start at boot:
    ```shell
    sudo launchctl load -w /Library/LaunchDaemons/com.apple.pfctl-myname.plist
    ```
    ```
    and disabled:
    ```shell
    sudo launchctl unload -w /Library/LaunchDaemons/com.apple.pfctl-myname.plist
    ```

  3. sohgoh revised this gist Dec 21, 2015. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions forwarding-example.md
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    Add the following to `/etc/pf.anchors/myname`:
    ```shell
    // 以前は port {80 8080} -> 127.0.0.1 port 8080 みたいな書き方が出来たけど今は無視されるので注意
    rdr pass on lo0 inet proto tcp from any to any port 80 -> 127.0.0.1 port 4000
    rdr pass on lo0 inet proto tcp from any to any port 443 -> 127.0.0.1 port 4001
    ```
  4. @f1sherman f1sherman renamed this gist Oct 10, 2015. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  5. @f1sherman f1sherman created this gist Oct 10, 2015.
    41 changes: 41 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,41 @@
    Add the following to `/etc/pf.anchors/myname`:
    ```shell
    rdr pass on lo0 inet proto tcp from any to any port 80 -> 127.0.0.1 port 4000
    rdr pass on lo0 inet proto tcp from any to any port 443 -> 127.0.0.1 port 4001
    ```

    Add the following to `/etc/pf-myname.conf`:
    ```shell
    rdr-anchor "forwarding"
    load anchor "forwarding" from "/etc/pf.anchors/myname"
    ```

    Add the following to `/Library/LaunchDaemons/com.apple.pfctl-myname.plist`:
    ```xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
    <key>Label</key>
    <string>com.apple.pfctl-myname</string>
    <key>Program</key>
    <string>/sbin/pfctl</string>
    <key>ProgramArguments</key>
    <array>
    <string>pfctl</string>
    <string>-e</string>
    <string>-f</string>
    <string>/etc/pf-myname.conf</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>KeepAlive</key>
    <false/>
    </dict>
    </plist>
    ```

    Run the following command to have it start at boot:
    ```shell
    sudo launchctl load -w /Library/LaunchDaemons/com.apple.pfctl-myname.plist
    ```