내 목적에 맞게 nginx 구성

내 목적에 맞게 nginx 구성

nginx.conf다음 작업에 따라 편집하는 데 도움을 줄 수 있는 사람이 있습니까 ? 기본 구성을 완료했습니다. 다음은 아직 설정해야 할 옵션 목록입니다(아직 설정하지 않았습니다).

1.Image files should be served by nginx with "Expires: 21 days" header added 
2.Logging of requests to "/somelogo.ico" should be disabled. All other requests should be proxied to another web server running on
local IP address on port 8080
3.Virtual host should accept requests to all "test.org" subdomains;

여기 내nginx.conf

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;



events {
    worker_connections 1024;
}

http {

  log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
 '$status $body_bytes_sent "$http_referer" '
 '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/test.org/access.log  main;


   server {
      location / {
                    root     /var/www/test.org/html;
             }
       location /images/ {
                root  /var/www/test.org/images;
             }
          }
       }

답변1

이 시도:

URI를 사용하여 Proxy_pass 지시어를 지정한 경우:

location / {
    proxy_pass      http://127.0.0.1:8080/mapped_dir/;
    proxy_set_header    Host            $host;
}

그 다음에

test.org/xxxxx will proxy to  http://127.0.0.1:8080/mapped_dir/xxxxx

회의

user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;

events {
    worker_connections 1024;
}

http {

  log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
 '$status $body_bytes_sent "$http_referer" '
 '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/test.org/access.log  main;


   server {
      listen 80;
      # handle requests containing anything.test.org in the HTTP header hosts field
      server_name *.test.org;

    location / {
        proxy_pass      http://127.0.0.1:8080/mapped_dir/;
        proxy_set_header    Host            $host;
    }
       location /images/ {
                root  /var/www/test.org/images;
                add_header "Expires:" "21 days" always;
             }
       # turn off logging for requests to /somelogo.ico
       location /somelogo.ico {
             access_log off;
          }
       }

관련 지침에 대한 정보

관련 정보