DaemonForums  

Go Back   DaemonForums > OpenBSD > OpenBSD General

OpenBSD General Other questions regarding OpenBSD which do not fit in any of the categories below.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 2nd August 2019
jonsec jonsec is offline
Port Guard
 
Join Date: Jul 2019
Posts: 24
Smile [httpd] 'fastcgi param' syntax error [Solved]

hi. i cant set fastcgi param and i get syntax error.

httpd.conf
Code:
prefork 10

server "test.example.com" {

    ...

    location match "^.+%.php$" {
        fastcgi socket "/run/php-fpm-example"
        fastcgi param HTTP_HOST "test.example.com" <--- syntax error
    }

    ...   

}

---------------------------------[Solved]

answer : httpd in OpenBSD 6.4 not support fastcgi param syntax.

Last edited by jonsec; 5th August 2019 at 07:01 PM.
Reply With Quote
  #2   (View Single Post)  
Old 2nd August 2019
PapaParrot's Avatar
PapaParrot PapaParrot is offline
parrot
 
Join Date: Jul 2015
Location: Durango, Mx.
Posts: 413
Default

This is kind of a wild guess, but looking at: https://man.openbsd.org/httpd.conf
Code:
$HTTP_HOST
The host from the HTTP Host header.
%n The capture index n of a string that was captured by the enclosing location match option.
There is no variable :
Code:
HTTP_HOST
shown, so I am guessing maybe the $ is important part of the variable.
Reply With Quote
  #3   (View Single Post)  
Old 2nd August 2019
jonsec jonsec is offline
Port Guard
 
Join Date: Jul 2019
Posts: 24
Unhappy

Quote:
Originally Posted by GarryR View Post
This is kind of a wild guess, but looking at: https://man.openbsd.org/httpd.conf
Code:
$HTTP_HOST
The host from the HTTP Host header.
%n The capture index n of a string that was captured by the enclosing location match option.
There is no variable :
Code:
HTTP_HOST
shown, so I am guessing maybe the $ is important part of the variable.
hmmm. no.
i change
Code:
fastcgi param HTTP_HOST "test.example.com"
to
Code:
fastcgi param $HTTP_HOST "test.example.com"
but problem not solved.
Reply With Quote
  #4   (View Single Post)  
Old 2nd August 2019
PapaParrot's Avatar
PapaParrot PapaParrot is offline
parrot
 
Join Date: Jul 2015
Location: Durango, Mx.
Posts: 413
Default

What about :
Code:
 fastcgi param  HTTP on;
http://daemonforums.org/showthread.php?t=8965
Might help you, but it is Nginx and that is also what I use, I don't normaly use httpd, and am not at all a expert.
I think it would help if you could give more information, like show the complete httpd.conf, and also some explanantion about what what you need to accomplish, I did a lot of searching, and did not find anything using a line like what you show,
Code:
 fastcgi param HTTP_HOST "test.example.com"
Where did you get that example ? The more details you give, the more someone can help, a description about what your server needs to do, why you need "prefork 10" ? It might seem irrelevant, but with better details, I think I could find some better examples, that fit your situation better. There is a lot of information available, but I do not know enough about your goal,and system to be able to guess at what might best apply.
======edited===
This is one document I found that might help you: https://www.openbsd.org/papers/httpd-asiabsdcon2015.pdf
====================
http://www.protoc.org/blog/2014/11/2...-httpd-server/
__________________
My best friends are parrots

Last edited by PapaParrot; 3rd August 2019 at 12:08 AM. Reason: added info
Reply With Quote
  #5   (View Single Post)  
Old 4th August 2019
PapaParrot's Avatar
PapaParrot PapaParrot is offline
parrot
 
Join Date: Jul 2015
Location: Durango, Mx.
Posts: 413
Default

I finally found this again. I had seen it,wanted to share it but got interrupted, and had not saved the url:
https://www.openbsd.org/httpd.conf

Not knowing what you are trying to do exactly makes it hard to suggest much, however you might be able to use the above as a guide and template, modify to suit your needs,
Note, in the code they use, no where do they use a line like what you have:
Code:
fastcgi param HTTP_HOST "test.example.com"
In fact, you might try with out that line a see what you get as well,...with out seeing the entire httpd.conf , it is hard to say.
You should also see this: https://man.openbsd.org/bgplg.8
It may be of help to you.
__________________
My best friends are parrots
Reply With Quote
  #6   (View Single Post)  
Old 4th August 2019
jonsec jonsec is offline
Port Guard
 
Join Date: Jul 2019
Posts: 24
Thumbs up

thanks PapaParrot.

i love OpenBSD Because its slogan is "Secure by Default".
OpenBSD is Good until No get into government matters or any other service.
OpenBSD Must has to stay clean.
i think OpenBSD has Clear future.

so i love use httpd for better security and performance.

Quote:
Where did you get that example ?
nowhere.

https://man.openbsd.org/httpd.conf.5
i read this document.

and find below docs :
Code:
[no] fastcgi [option]
    Enable FastCGI instead of serving files. Valid options are:

    socket socket
        httpd passes HTTP requests to a FastCGI handler listening on the socket socket. The socket can either be a UNIX domain socket or a TCP socket listening on localhost (127.0.0.1). If the FastCGI handler is listening on a UNIX domain socket, socket is a local path name within the chroot(2) root directory of httpd(8) and defaults to /run/slowcgi.sock. Alternatively if the FastCGI handler is listening on a TCP socket, socket starts with a colon followed by the TCP port number.
    param variable value
        Sets a variable that will be sent to the FastCGI server. Each statement defines one variable.

    The FastCGI handler will be given the following variables by default:

    DOCUMENT_ROOT
        The document root in which the script is located as configured by the root option for the server or location that matches the request.
    GATEWAY_INTERFACE
        The revision of the CGI specification used.
    HTTP_*
        Additional HTTP headers the connected client sent in the request, if any.
    HTTPS
        A variable that is set to “on” when the server has been configured to use TLS. This variable is omitted otherwise.
    REQUEST_URI
        The path and optional query string as requested by the connected client.
    DOCUMENT_URI
        The canonicalized request path, possibly with a slash or directory index file name appended. This is the same as PATH_INFO appended to SCRIPT_NAME.
    SCRIPT_NAME
        The virtual URI path to the script.
    PATH_INFO
        The optional path appended after the script name in the request path. This variable is an empty string if no path is appended after the script name.
    SCRIPT_FILENAME
        The absolute, physical path to the script within the chroot(2) directory.
    QUERY_STRING
        The optional query string of the request. This variable is an empty string if there is no query string in the request.
    REMOTE_ADDR
        The IP address of the connected client.
    REMOTE_PORT
        The TCP source port of the connected client.
    REMOTE_USER
        The remote user when using HTTP authentication.
    REQUEST_METHOD
        The HTTP method the connected client used when making the request.
    SERVER_ADDR
        The configured IP address of the server.
    SERVER_NAME
        The name of the server.
    SERVER_PORT
        The configured TCP server port of the server.
    SERVER_PROTOCOL
        The revision of the HTTP specification used.
    SERVER_SOFTWARE
        The server software name of httpd(8).
    TLS_PEER_VERIFY
        A variable that is set to a comma separated list of TLS client verification features in use (omitted when TLS client verification is not in use).
so `fastcgi param` how work?

httpd configuration must provide required feature for developers.
for example i have three server in different domains and i want use set `Access-Control-Allow-Origin` in header for static file.
how i can?
for dynamic page is possible. for example you can set this header(Access-Control-Allow-Origin) by php.
also for static page is possible but no with httpd.we can use php(fastcgi) for handle static file for more maneuverability But it may have optimization and security issues.
Reply With Quote
  #7   (View Single Post)  
Old 4th August 2019
PapaParrot's Avatar
PapaParrot PapaParrot is offline
parrot
 
Join Date: Jul 2015
Location: Durango, Mx.
Posts: 413
Default

The problem I am having, everything I find that goes into a lot of detail is for Nginx and not Httpd (apache). I have been trying myself using httpd, and no results that work. This leads to why I ended up using Nginx myself, instead of httpd.
I do notice no one else has jumped in here, with any suggestions, indicates to me mayve no one knows .My suggestion is to ask at this mailing list:
Quote:
From https://www.openbsd.org/mail.html misc@openbsd.org
User questions and answers, general questions. This is the most active list. Please read the FAQ and the installation documents, and see how to report a problem before posting.
(Archive)
There also is a list of professionals here: https://www.openbsd.org/support.html
I used one I found here ^above^ to help me with my server, you will notice there are various in many different countries, obviously one that is from the same country, and speaks/writes in your native language would be best.
I will keep trying to do something with httpd, but do not have much free time, and also am not at all a expert, but if I come up with something that works I will post about it here.
I am thinking maybe with just the default httpd, that comes with the OpenBsd 6.5 , it is not enough and additional packages are needed, but not sure on that.
__________________
My best friends are parrots
Reply With Quote
  #8   (View Single Post)  
Old 4th August 2019
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 6,799
Default

Hi, jonsec. The error is not in your param setting. The location{} directive inside the server{} directive needs a closing brace.
Reply With Quote
  #9   (View Single Post)  
Old 5th August 2019
PapaParrot's Avatar
PapaParrot PapaParrot is offline
parrot
 
Join Date: Jul 2015
Location: Durango, Mx.
Posts: 413
Default

I am sorry, I did not see that, but also still am not sure exactly what you mean Jggimi, should it be like this ?:
Code:
 prefork 10

server "test.example.com" {

...
}
location match "^.+%.php$" {
fastcgi socket "/run/php-fpm-example"
fastcgi param HTTP_HOST "test.example.com" <--- syntax error
}

...

}
Thanks
__________________
My best friends are parrots
Reply With Quote
Old 5th August 2019
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 6,799
Default

I am only able to reproduce your syntax error when I remove the server{} closing brace. This example has no error:
Code:
server test {
   listen on * port 80
   location match "^.+%.php$" {
      fastcgi socket "/run/php-fpm-example"
      fastcgi param HTTP_HOST "test.example.com"
   }
}
If I remove either of the two closing braces and leave only one, I get a syntax error.
Reply With Quote
Old 5th August 2019
PapaParrot's Avatar
PapaParrot PapaParrot is offline
parrot
 
Join Date: Jul 2015
Location: Durango, Mx.
Posts: 413
Default

Thanks, to me that is clear now. Hopefully the same for the OP. You are right, just one little thing like that, or a typo can and does cause "syntax errors".
Reply With Quote
Old 5th August 2019
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 882
Default

I'm confused, because the code block in the first post seems to have 2 closing braces?
Reply With Quote
Old 5th August 2019
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 6,799
Default

The posted information was not a complete configuration file, only redacted excerpts. A missing brace is a syntax error, with many possible reported line number impacts, depending on the configuration file structure and {} uses.
Reply With Quote
Old 5th August 2019
jonsec jonsec is offline
Port Guard
 
Join Date: Jul 2019
Posts: 24
Exclamation

Quote:
Originally Posted by jggimi View Post
I am only able to reproduce your syntax error when I remove the server{} closing brace. This example has no error:
Code:
server test {
   listen on * port 80
   location match "^.+%.php$" {
      fastcgi socket "/run/php-fpm-example"
      fastcgi param HTTP_HOST "test.example.com"
   }
}
If I remove either of the two closing braces and leave only one, I get a syntax error.
i replace your code in httpd.conf but i still have syntax error.(on line 5)
Reply With Quote
Old 5th August 2019
IdOp's Avatar
IdOp IdOp is offline
Too dumb for a smartphone
 
Join Date: May 2008
Location: twisting on the daemon's fork(2)
Posts: 882
Default

Quote:
Originally Posted by jggimi View Post
The posted information was not a complete configuration file, only redacted excerpts.
That's right, a missing-brace error could be hidden in one of the redacted "..." parts, yet impact the indicated line. I think we really need to see an entire configuration file that contains the error.
Reply With Quote
Old 5th August 2019
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 6,799
Default

Quote:
Originally Posted by jonsec View Post
i replace your code in httpd.conf but i still have syntax error.(on line 5)
What release of OpenBSD are you using? You can obtain this with $ sysctl kern.version.
Reply With Quote
Old 5th August 2019
PapaParrot's Avatar
PapaParrot PapaParrot is offline
parrot
 
Join Date: Jul 2015
Location: Durango, Mx.
Posts: 413
Default

Httpd needs to be restarted when the conf file is changed, I am sure you know that, but just in case.
Can you show us the complete configuration file ? Also this:
Code:
/run/php-fpm-example
Does httpd start ok with out any of the "CGI" parts ?
Also is your php-fpm started ok ?
__________________
My best friends are parrots
Reply With Quote
Old 5th August 2019
jonsec jonsec is offline
Port Guard
 
Join Date: Jul 2019
Posts: 24
Lightbulb

Quote:
Originally Posted by jggimi View Post
What release of OpenBSD are you using? You can obtain this with $ sysctl kern.version.
OpenBSD 6.4
Reply With Quote
Old 5th August 2019
jonsec jonsec is offline
Port Guard
 
Join Date: Jul 2019
Posts: 24
Default

Quote:
Originally Posted by PapaParrot View Post
Httpd needs to be restarted when the conf file is changed, I am sure you know that, but just in case.
Can you show us the complete configuration file ? Also this:
Code:
/run/php-fpm-example
Does httpd start ok with out any of the "CGI" parts ?
Also is your php-fpm started ok ?
i use below code and delete last codes , but i have syntax error.

Code:
server test {
   listen on * port 80
   location match "^.+%.php$" {
      fastcgi socket "/run/php-fpm-example"
      fastcgi param HTTP_HOST "test.example.com"
   }
}
Quote:
Does httpd start ok with out any of the "CGI" parts ?
yes

Quote:
Also is your php-fpm started ok ?
yes
Reply With Quote
Old 5th August 2019
jggimi's Avatar
jggimi jggimi is offline
More noise than signal
 
Join Date: May 2008
Location: USA
Posts: 6,799
Default

Quote:
Originally Posted by jonsec View Post
OpenBSD 6.4
This is your problem. The fastcgi syntax you are using is from OpenBSD 6.5.

You are using OpenBSD 6.4 but not referring to the OpenBSD httpd.conf(5) man page from that release.
  • If you are using the OpenBSD man pages at man.openbsd.org, you may not realize these are -current man pages by default, and you must select your release.
  • Man pages are available locally if you installed the man64.tgz fileset. Try $ man httpd.conf to obtain the man page that matches your release.
You will want to upgrade to 6.5 if you want to set these parameters.

Last edited by jggimi; 5th August 2019 at 06:59 PM. Reason: clarity
Reply With Quote
Reply

Tags
httpd, httpd fastcgi

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
ipsec.conf Syntax error Dr-D OpenBSD Security 8 14th November 2018 11:57 PM
httpd fastcgi configuration and programming hanzer OpenBSD General 11 27th February 2015 01:45 PM
Pf.conf:29 syntax error CyberJet OpenBSD Security 17 3rd May 2013 06:41 PM
Am I blind? syntax error: `(' unexpected guitarscn Programming 1 10th November 2010 08:53 PM
shc unistd.h:239: error: syntax error before '&' token laraaj OpenBSD General 3 11th September 2010 07:21 AM


All times are GMT. The time now is 12:00 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick