67
47

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

nginxのproxy_passでハマった

Posted at

/api/ではじまるURLをすべてlocalhost:8080で処理したい。

location /api/ {
    proxy_pass http://localhost:8080/;
}

http://localhost/api/hoge/にアクセスするも404。
http://localhost:8080/api/hoge/ではちゃんと結果が返ってくる。

ググった結果解決。

proxy_pass http://localhost:8080/;
と設定した場合、
http://localhost:8080/hoge/とアクセスされるようだ。/api/の部分が省略されてしまう。

proxy_pass http://localhost:8080;
とすると(最後のスラッシュを消しただけ)、
http://localhost:8080/api/hoge/に正しくアクセスされた。

軽くハマったのでメモ。

67
47
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
67
47

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?