我在 ubuntu 中设置了一个 nginx 服务器作为反向代理缓存服务器。我的应用程序代码位于 /var/www/myapp 文件夹中。
以下是我给出的配置
server {
listen 80; ## listen for ipv4; this line is default and implied
root /var/www/;
index index.html index.htm;
# Make site accessible from http://localhost/
server_name localhost;
location / {
proxy_pass http://127.0.0.1:8080/;
rewrite ^([^.]*[^/])$ $1/ permanent;
add_header X-Cache-Status $upstream_cache_status;
}
location /doc/ {
alias /usr/share/doc/;
autoindex on;
allow 127.0.0.1;
deny all;
}
}
Run Code Online (Sandbox Code Playgroud)
是我的 nginx/sites-available/default 文件的内容
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 1024 ;
# multi_accept on;
}
http …Run Code Online (Sandbox Code Playgroud)