Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- server {
- listen 443 ssl;
- listen [::]:443 ssl;
- server_name server-name.ru;
- include /etc/nginx/snippets/ssl.conf;
- location /test {
- set_real_ip_from uplink_ip;
- real_ip_header X-Forwarded-For;
- allow uplink_ip;
- deny all;
- proxy_pass http://192.168.1.1;
- include /etc/nginx/proxy_params;
- include /etc/nginx/cors;
- proxy_read_timeout 600;
- }
- }
- --- proxy_params
- proxy_set_header Host $http_host;
- proxy_set_header X-Real-IP $remote_addr;
- proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
- proxy_set_header X-Forwarded-Proto $scheme;
- --- cors
- if ($request_method = 'OPTIONS') {
- add_header 'Access-Control-Allow-Origin' '*';
- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
- #
- # Custom headers and headers various browsers *should* be OK with but aren't
- #
- add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,x-redmine-api-key';
- #
- # Tell client that this pre-flight info is valid for 20 days
- #
- add_header 'Access-Control-Max-Age' 1728000;
- add_header 'Content-Type' 'text/plain; charset=utf-8';
- add_header 'Content-Length' 0;
- return 204;
- }
- if ($request_method = 'POST') {
- add_header 'Access-Control-Allow-Origin' '*';
- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
- add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,x-redmine-api-key';
- add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
- }
- if ($request_method = 'GET') {
- add_header 'Access-Control-Allow-Origin' '*';
- add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
- add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range,x-redmine-api-key';
- add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
- }
- --- access.log
- client_ip - - [27/Feb/2023:11:47:56 +0300] "GET /test HTTP/1.1" 403 180 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/110.0.0.0 Safari/537.36"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement