LoginSignup
0
0

More than 3 years have passed since last update.

Nginx と Gin の連携

Last updated at Posted at 2021-01-29

こちらのサンプル example.go を Nginx 経由でアクセスできるようにします。
リバースプロキシで、ポートフォワードをします。

直接 Gin にアクセスする場合

curl http://localhost:8080/ping

Nginx 経由でアクセスする場合

curl http://localhost/ping

Nginx の設定

/etc/nginx/nginx.conf
(省略)
location   ^~ /ping {
        proxy_pass   http://127.0.0.1:8080/ping;
}
(省略)

設定が正しいことの確認

sudo nginx -t

Nginx の再起動

sudo systemctl restart nginx

次のようなエラーが出ることがあります。

/var/log/nginx/error.log
(13: Permission denied) while connecting to upstream

次で解決します。

sudo setsebool -P httpd_can_network_connect 1
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0