1

I have 2 links: myserver.org and myserver.org/support I need first link follow to /var/www/myserver.org and second to /var/www/support My config now: first file & link

server { listen 80 default_server; server_name groupmanager.org; charset utf-8; root /var/www/groupmanager.org; index index.php; location / { try_files $uri $uri/ /index.php?$query_string; } access_log /var/log/nginx/groupmanager.org_access.log; error_log /var/log/nginx/groupmanager.org_error.log; include /etc/nginx/templates/php-fpm.conf; } server { listen 80; server_name www.groupmanager.org; rewrite ^(.*) http://groupmanager.org$1 permanent; } 

Second file & link:

server { listen 80; server_name 163.172.88.31/support; charset utf-8; root /var/www/support; index index.php; access_log /var/log/nginx/support_access.log; error_log /var/log/nginx/support_error.log; include /etc/nginx/templates/php-fpm.conf; } server { listen 80; server_name www.163.172.88.31/support; rewrite ^(.*) http://163.172.88.31/support$1 permanent; } 

php-fpm.conf

location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } location ~ /\.ht { deny all; } location ~* \.(gif|jpeg|jpg|txt|png|tif|tiff|ico|jng|bmp|doc|pdf|rtf|xls|ppt|rar|rpm|swf|zip|bin|exe|dll|deb|cur)$ { expires 168h; } location ~* \.(css|js)$ { expires 180m; } 

First link works fine, second - no. I see '403 Forbidden' What is not rigth? Permissions for folders are the same, I think, they are right.

3 Answers 3

1

For both /var/www/myserver.org and /var/www/support you have to make two separate nginx config file with two different roots and server names .

besides , if you just want to show two links you can setup nginx for one and link the second one with just an internal link ( if they are in the same page)

Sign up to request clarification or add additional context in comments.

1 Comment

Now I use ip to access. Two files not works. All requests follow in first file.
0

Try like this:

 include /etc/nginx/default.d/*.conf; server { listen 80 default_server; server_name myserver.org; charset utf-8; root /var/www/myserver.org; index index.php; include /etc/nginx/default.d/*.conf; location / { try_files $uri $uri/ /index.php?$query_string; } 

in /etc/nginx/default.d/ directory , create a .config file test.config:

location myserver.org { proxy_pass /myserver.org; } location myserver.org/support { proxy_pass /var/www/support; } 

3 Comments

What changes when I write it two times? I see the same error.
can u share the error and all ur nginx.config file ?
Error:Job for nginx.service failed. See 'systemctl status nginx.service' and 'journalctl -xn' for details. nginx: [emerg] "location" directive is not allowed here in /etc/nginx/default.d/test.conf:1
0

This works:

groupmanager.org.conf

server { listen 80 default_server; server_name groupmanager.org; charset utf-8; root /var/www/groupmanager.org; index index.php; location /support/ { alias /var/www/support/; index index.php; access_log /var/log/nginx/support_access.log; error_log /var/log/nginx/support_error.log; location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME /var/www/$fastcgi_script_name; } } access_log /var/log/nginx/groupmanager.org_access.log; error_log /var/log/nginx/groupmanager.org_error.log; include /etc/nginx/templates/php-fpm.conf; } server { listen 80; server_name www.groupmanager.org; rewrite ^(.*) http://groupmanager.org$1 permanent; } 

php-fpm.conf

location ~ \.php$ { try_files $uri =404; fastcgi_pass unix:/var/run/php/php7.0-fpm.sock; fastcgi_index index.php; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } location ~ /\.ht { deny all; } location ~* \.(gif|jpeg|jpg|txt|png|tif|tiff|ico|jng|bmp|doc|pdf|rtf|xls|ppt|rar|rpm|swf|zip|bin|exe|dll|deb|cur)$ { expires 168h; } location ~* \.(css|js)$ { expires 180m; } 

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.