Skip to content

Instantly share code, notes, and snippets.

@ismiyati
Forked from atomaths/nginx.conf
Created February 12, 2020 17:59
Show Gist options
  • Select an option

  • Save ismiyati/aedf6cd77fb923b756f908bd61e0ee60 to your computer and use it in GitHub Desktop.

Select an option

Save ismiyati/aedf6cd77fb923b756f908bd61e0ee60 to your computer and use it in GitHub Desktop.

Revisions

  1. @atomaths atomaths revised this gist Dec 23, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -6,13 +6,13 @@ server {
    }
    }

    ## Reverse Proxy
    ## Reverse Proxy (이 방식으로 하면 http.ListenAndServe로 해야함)
    server {
    listen 80;
    # listen 443 ssl;
    server_name api.golang.org;

    location / {
    location ~ / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header Host $host;
  2. @atomaths atomaths revised this gist Dec 23, 2013. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -1,15 +1,15 @@
    // FastCGI
    ## FastCGI
    server {
    location ~ /app.* {
    fastcgi_pass 127.0.0.1:9000;
    include fastcgi_params;
    }
    }

    // Reverse Proxy
    ## Reverse Proxy
    server {
    listen 80;
    // listen 443 ssl;
    # listen 443 ssl;
    server_name api.golang.org;

    location / {
  3. @atomaths atomaths revised this gist Dec 23, 2013. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -1,10 +1,12 @@
    // FastCGI
    server {
    location ~ /app.* {
    fastcgi_pass 127.0.0.1:9000;
    include fastcgi_params;
    }
    }

    // Reverse Proxy
    server {
    listen 80;
    // listen 443 ssl;
  4. @atomaths atomaths revised this gist Dec 23, 2013. 1 changed file with 13 additions and 0 deletions.
    13 changes: 13 additions & 0 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -3,4 +3,17 @@ server {
    fastcgi_pass 127.0.0.1:9000;
    include fastcgi_params;
    }
    }

    server {
    listen 80;
    // listen 443 ssl;
    server_name api.golang.org;

    location / {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $remote_addr;
    proxy_set_header Host $host;
    proxy_pass http://127.0.0.1:3000;
    }
    }
  5. @atomaths atomaths revised this gist Apr 23, 2013. 1 changed file with 15 additions and 0 deletions.
    15 changes: 15 additions & 0 deletions server2.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    // 아래처럼 HandleFunc를 등록해서도 처리가능

    func main() {
    http.HandleFunc("/foo", fooHandler)

    l, err := net.Listen("tcp", "127.0.0.1:9000")
    if err != nil {
    panic(err)
    }
    fcgi.Serve(l, nil)
    }

    func fooHandler(w http.ResponseWriter, r *http.Request) {
    fmt.Fprintf(w, "Hello")
    }
  6. @atomaths atomaths created this gist Apr 17, 2013.
    6 changes: 6 additions & 0 deletions nginx.conf
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    server {
    location ~ /app.* {
    fastcgi_pass 127.0.0.1:9000;
    include fastcgi_params;
    }
    }
    21 changes: 21 additions & 0 deletions server.go
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,21 @@
    package main

    import (
    "fmt"
    "net/http"
    "net/http/fcgi"
    "net"
    )

    type FastCGIServer struct{}

    func (s FastCGIServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
    w.Write([]byte("This is a FastCGI example server.\n"))
    }

    func main() {
    fmt.Println("Starting server...")
    l, _ := net.Listen("tcp", "127.0.0.1:9000")
    b := new(FastCGIServer)
    fcgi.Serve(l, b)
    }